diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..fde0c20f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "public/amtl"] + path = public/amtl + url = https://github.com/alliedmodders/amtl +[submodule "sourcepawn"] + path = sourcepawn + url = https://github.com/alliedmodders/sourcepawn diff --git a/.travis.yml b/.travis.yml index 46019885..e0576367 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,19 @@ compiler: - clang before_script: - sudo apt-get update -qq - - sudo apt-get install -y g++-multilib libc6-dev-i386 lib32stdc++6 lib32z1-dev + - sudo apt-get install -y python-software-properties + - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/ppa + - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + - sudo apt-get update -qq + - sudo apt-get install -qq g++-4.8 + - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90 + - echo "deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.5 main" | sudo tee --append /etc/apt/sources.list + - echo "deb-src http://llvm.org/apt/precise/ llvm-toolchain-precise-3.5 main" | sudo tee --append /etc/apt/sources.list + - wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - + - sudo apt-get update -qq + - sudo apt-get install -y g++-multilib libc6-dev-i386 lib32stdc++6 lib32z1-dev clang-3.5 - CHECKOUT_DIR=$PWD && cd .. && $CHECKOUT_DIR/tools/checkout-deps.sh && cd $CHECKOUT_DIR script: - mkdir build && cd build - - python ../configure.py --enable-optimize --sdks=episode1,tf2,l4d2,csgo,dota + - CC=clang-3.5 CXX=clang-3.5 python ../configure.py --enable-optimize --sdks=episode1,tf2,l4d2,csgo,dota - ambuild \ No newline at end of file diff --git a/AMBuildScript b/AMBuildScript index d2b99d54..3596c751 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -23,20 +23,21 @@ PossibleSDKs = { 'hl2dm': SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'), 'dods': SDK('HL2SDKDODS', '2.dods', '8', 'DODS', WinLinuxMac, 'dods'), 'sdk2013': SDK('HL2SDK2013', '2.sdk2013', '9', 'SDK2013', WinLinuxMac, 'sdk2013'), - 'tf2': SDK('HL2SDKTF2', '2.tf2', '10', 'TF2', WinLinuxMac, 'tf2'), - 'l4d': SDK('HL2SDKL4D', '2.l4d', '11', 'LEFT4DEAD', WinLinuxMac, 'l4d'), - 'nucleardawn': SDK('HL2SDKND', '2.nd', '12', 'NUCLEARDAWN', WinLinuxMac, 'nucleardawn'), - 'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '14', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'), + 'tf2': SDK('HL2SDKTF2', '2.tf2', '11', 'TF2', WinLinuxMac, 'tf2'), + 'l4d': SDK('HL2SDKL4D', '2.l4d', '12', 'LEFT4DEAD', WinLinuxMac, 'l4d'), + 'nucleardawn': SDK('HL2SDKND', '2.nd', '13', 'NUCLEARDAWN', WinLinuxMac, 'nucleardawn'), + 'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '15', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'), 'darkm': SDK('HL2SDK-DARKM', '2.darkm', '2', 'DARKMESSIAH', WinOnly, 'darkm'), - 'swarm': SDK('HL2SDK-SWARM', '2.swarm', '15', 'ALIENSWARM', WinOnly, 'swarm'), + 'swarm': SDK('HL2SDK-SWARM', '2.swarm', '16', 'ALIENSWARM', WinOnly, 'swarm'), 'bgt': SDK('HL2SDK-BGT', '2.bgt', '4', 'BLOODYGOODTIME', WinOnly, 'bgt'), 'eye': SDK('HL2SDK-EYE', '2.eye', '5', 'EYE', WinOnly, 'eye'), - 'csgo': SDK('HL2SDKCSGO', '2.csgo', '19', 'CSGO', WinLinuxMac, 'csgo'), - 'dota': SDK('HL2SDKDOTA', '2.dota', '20', 'DOTA', WinLinuxMac, 'dota'), - 'portal2': SDK('HL2SDKPORTAL2', '2.portal2', '16', 'PORTAL2', [], 'portal2'), - 'blade': SDK('HL2SDKBLADE', '2.blade', '17', 'BLADE', WinLinux, 'blade'), - 'insurgency': SDK('HL2SDKINSURGENCY', '2.insurgency', '18', 'INSURGENCY', WinLinuxMac, 'insurgency'), - 'contagion': SDK('HL2SDKCONTAGION', '2.contagion', '13', 'CONTAGION', WinOnly, 'contagion'), + 'csgo': SDK('HL2SDKCSGO', '2.csgo', '20', 'CSGO', WinLinuxMac, 'csgo'), + 'dota': SDK('HL2SDKDOTA', '2.dota', '21', 'DOTA', WinLinuxMac, 'dota'), + 'portal2': SDK('HL2SDKPORTAL2', '2.portal2', '17', 'PORTAL2', [], 'portal2'), + 'blade': SDK('HL2SDKBLADE', '2.blade', '18', 'BLADE', WinLinux, 'blade'), + 'insurgency': SDK('HL2SDKINSURGENCY', '2.insurgency', '19', 'INSURGENCY', WinLinuxMac, 'insurgency'), + 'contagion': SDK('HL2SDKCONTAGION', '2.contagion', '14', 'CONTAGION', WinOnly, 'contagion'), + 'bms': SDK('HL2SDKBMS', '2.bms', '10', 'BMS', WinLinux, 'bms'), } def ResolveEnvPath(env, folder): @@ -172,7 +173,7 @@ class SMConfig(object): '-m32', ] cxx.cxxflags += [ - '-std=c++11', + '-std=c++11', ] have_gcc = cxx.vendor == 'gcc' @@ -216,8 +217,6 @@ class SMConfig(object): '_CRT_NONSTDC_NO_DEPRECATE', '_ITERATOR_DEBUG_LEVEL=0', ] - if cxx.version < 1800: - cxx.defines += 'strtoull=_strtoui64' cxx.cflags += [ '/W3', ] @@ -228,7 +227,6 @@ class SMConfig(object): ] cxx.linkflags += [ '/MACHINE:X86', - '/SUBSYSTEM:WINDOWS', 'kernel32.lib', 'user32.lib', 'gdi32.lib', @@ -266,6 +264,7 @@ class SMConfig(object): # Platform-specifics if builder.target_platform == 'linux': cxx.defines += ['_LINUX', 'POSIX'] + cxx.linkflags += ['-lm'] if cxx.vendor == 'gcc': cxx.linkflags += ['-static-libgcc'] elif cxx.vendor == 'clang': @@ -288,10 +287,15 @@ class SMConfig(object): 'SOURCEMOD_BUILD', 'SM_USE_VERSIONLIB', ] + cxx.includes += [ + os.path.join(builder.sourcePath, 'public'), + ] if self.use_auto_versioning(): cxx.defines += ['SM_GENERATED_BUILD'] - cxx.includes += [os.path.join(builder.buildPath, 'includes')] - cxx.includes += [os.path.join(builder.sourcePath, 'versionlib')] + cxx.includes += [ + os.path.join(builder.buildPath, 'includes'), + os.path.join(builder.sourcePath, 'versionlib'), + ] def AddVersioning(self, binary): if builder.target_platform == 'windows': @@ -315,20 +319,23 @@ class SMConfig(object): def Library(self, context, name): binary = context.compiler.Library(name) + if binary.compiler.like('msvc'): + binary.compiler.linkflags += ['/SUBSYSTEM:WINDOWS'] return self.AddVersioning(binary) def Program(self, context, name): binary = context.compiler.Program(name) + if binary.compiler.like('msvc'): + binary.compiler.linkflags += ['/SUBSYSTEM:CONSOLE'] return self.AddVersioning(binary) def ConfigureForExtension(self, context, compiler): compiler.cxxincludes += [ os.path.join(context.currentSourcePath), os.path.join(context.currentSourcePath, 'sdk'), - os.path.join(builder.sourcePath, 'public'), os.path.join(builder.sourcePath, 'public', 'extensions'), - os.path.join(builder.sourcePath, 'public', 'sourcepawn'), - os.path.join(builder.sourcePath, 'public', 'amtl'), + os.path.join(builder.sourcePath, 'sourcepawn', 'include'), + os.path.join(builder.sourcePath, 'public', 'amtl', 'include'), ] return compiler @@ -372,7 +379,7 @@ class SMConfig(object): compiler.defines += ['SOURCE_ENGINE=' + sdk.code] - if sdk.name == 'sdk2013' and compiler.like('gcc'): + if sdk.name in ['sdk2013', 'bms'] and compiler.like('gcc'): # The 2013 SDK already has these in public/tier0/basetypes.h compiler.defines.remove('stricmp=strcasecmp') compiler.defines.remove('_stricmp=strcasecmp') @@ -389,7 +396,7 @@ class SMConfig(object): if sdk.name in ['blade', 'insurgency', 'csgo', 'dota']: compiler.defines += ['NETWORK_VARS_ENABLED'] - if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'tf2', 'l4d', 'nucleardawn', 'l4d2', 'dota']: + if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2', 'dota']: if builder.target_platform in ['linux', 'mac']: compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE'] @@ -402,18 +409,18 @@ class SMConfig(object): if builder.target_platform == 'linux': if sdk.name == 'episode1': lib_folder = os.path.join(sdk.path, 'linux_sdk') - elif sdk.name == 'sdk2013': + elif sdk.name in ['sdk2013', 'bms']: lib_folder = os.path.join(sdk.path, 'lib', 'public', 'linux32') else: lib_folder = os.path.join(sdk.path, 'lib', 'linux') elif builder.target_platform == 'mac': - if sdk.name == 'sdk2013': + if sdk.name in ['sdk2013', 'bms']: lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32') else: lib_folder = os.path.join(sdk.path, 'lib', 'mac') if builder.target_platform in ['linux', 'mac']: - if sdk.name == 'sdk2013': + if sdk.name in ['sdk2013', 'bms']: compiler.postlink += [ compiler.Dep(os.path.join(lib_folder, 'tier1.a')), compiler.Dep(os.path.join(lib_folder, 'mathlib.a')) @@ -431,8 +438,7 @@ class SMConfig(object): dynamic_libs = [] if builder.target_platform == 'linux': - compiler.linkflags[0:0] = ['-lm'] - if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'nucleardawn', 'l4d2']: + if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2']: dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so'] elif sdk.name in ['l4d', 'blade', 'insurgency', 'csgo', 'dota']: dynamic_libs = ['libtier0.so', 'libvstdlib.so'] @@ -493,6 +499,18 @@ if SM.use_auto_versioning(): { 'SM': SM } ) +# Build SourcePawn externally. +SourcePawn = builder.RunScript('sourcepawn/AMBuildScript', {}) +SP = SourcePawn( + root = SM, + amtl = os.path.join(builder.sourcePath, 'public', 'amtl'), +) +SP.BuildCore() +SM.spcomp = SP.spcomp +SM.binaries += [ + SP.libsourcepawn +] + BuildScripts = [ 'loader/AMBuilder', 'core/AMBuilder', @@ -510,8 +528,6 @@ BuildScripts = [ 'extensions/tf2/AMBuilder', 'extensions/topmenus/AMBuilder', 'extensions/updater/AMBuilder', - 'sourcepawn/compiler/AMBuilder', - 'sourcepawn/jit/AMBuilder', ] if builder.backend == 'amb2': diff --git a/configs/cfg/sourcemod.cfg b/configs/cfg/sourcemod.cfg index 51476e8e..c4f7d97e 100644 --- a/configs/cfg/sourcemod.cfg +++ b/configs/cfg/sourcemod.cfg @@ -105,8 +105,8 @@ sm_timeleft_interval 0 // 1 (Enabled) // -- // Requires: basetriggers.smx -// Default: 1 -sm_trigger_show 1 +// Default: 0 +sm_trigger_show 0 // Specifies whether or not to display vote progress to clients in the // "hint" box (near the bottom of the screen in most games). diff --git a/core/AMBuilder b/core/AMBuilder index cf957682..4875903f 100644 --- a/core/AMBuilder +++ b/core/AMBuilder @@ -59,7 +59,7 @@ for sdk_name in SM.sdks: ] elif sdk.name == 'dota': compiler.cxxincludes += [ - os.path.join(sdk.path, 'common', 'protobuf-2.5.0', 'src'), + os.path.join(sdk.path, 'common', 'protobuf-2.6.1', 'src'), os.path.join(sdk.path, 'public', 'engine', 'protobuf'), os.path.join(sdk.path, 'public', 'game', 'shared', 'protobuf'), os.path.join(sdk.path, 'public', 'game', 'shared', 'dota', 'protobuf') @@ -78,12 +78,8 @@ for sdk_name in SM.sdks: vs_year = '' if msvc_ver == 1800: vs_year = '2013' - elif msvc_ver == 1700: - vs_year = '2012' - elif msvc_ver == 1600: - vs_year = '2010' else: - raise Exception('Cannot find libprotobuf for MSVC version "' + compiler.version + '"') + raise Exception('Cannot find libprotobuf for MSVC version "' + str(compiler.version) + '"') if 'DEBUG' in compiler.defines: lib_path = os.path.join(sdk.path, 'lib', 'win32', 'debug', 'vs' + vs_year, 'libprotobuf.lib') diff --git a/core/ConCmdManager.cpp b/core/ConCmdManager.cpp index e93c6cc3..26660767 100644 --- a/core/ConCmdManager.cpp +++ b/core/ConCmdManager.cpp @@ -218,6 +218,7 @@ ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int hook->pf->PushCell(args); cell_t tempres = result; + if (hook->pf->Execute(&tempres) == SP_ERROR_NONE) { if (tempres > result) diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 27b05305..3423072e 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -59,7 +59,8 @@ typedef ICommandLine *(*FakeGetCommandLine)(); #define VSTDLIB_NAME "libvstdlib.dylib" #elif defined __linux__ #if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \ - || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_LEFT4DEAD2 || SOURCE_ENGINE == SE_NUCLEARDAWN + || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_LEFT4DEAD2 || SOURCE_ENGINE == SE_NUCLEARDAWN \ + || SOURCE_ENGINE == SE_BMS #define TIER0_NAME "libtier0_srv.so" #define VSTDLIB_NAME "libvstdlib_srv.so" #elif SOURCE_ENGINE >= SE_LEFT4DEAD @@ -153,11 +154,12 @@ void CHalfLife2::OnSourceModAllInitialized_Post() void CHalfLife2::InitLogicalEntData() { -#if SOURCE_ENGINE == SE_TF2 \ - || SOURCE_ENGINE == SE_DODS \ - || SOURCE_ENGINE == SE_HL2DM \ - || SOURCE_ENGINE == SE_CSS \ - || SOURCE_ENGINE == SE_SDK2013 +#if SOURCE_ENGINE == SE_TF2 \ + || SOURCE_ENGINE == SE_DODS \ + || SOURCE_ENGINE == SE_HL2DM \ + || SOURCE_ENGINE == SE_CSS \ + || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS if (g_SMAPI->GetServerFactory(false)("VSERVERTOOLS003", nullptr)) { @@ -234,7 +236,7 @@ void CHalfLife2::InitLogicalEntData() void CHalfLife2::InitCommandLine() { char error[256]; - +#if SOURCE_ENGINE != SE_DARKMESSIAH if (!is_original_engine) { ke::AutoPtr lib(g_LibSys.OpenLibrary(TIER0_NAME, error, sizeof(error))); @@ -253,6 +255,7 @@ void CHalfLife2::InitCommandLine() } } else +#endif { ke::AutoPtr lib(g_LibSys.OpenLibrary(VSTDLIB_NAME, error, sizeof(error))); if (lib == NULL) @@ -497,7 +500,7 @@ bool CHalfLife2::TextMsg(int client, int dest, const char *msg) /* Use SayText user message instead */ if (chat_saytext != NULL && strcmp(chat_saytext, "yes") == 0) { - char buffer[192]; + char buffer[253]; UTIL_Format(buffer, sizeof(buffer), "%s\1\n", msg); #if SOURCE_ENGINE == SE_DOTA diff --git a/core/Makefile b/core/Makefile deleted file mode 100644 index 08f9dc8a..00000000 --- a/core/Makefile +++ /dev/null @@ -1,216 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = .. -HL2SDK_ORIG = ../../hl2sdk -HL2SDK_OB = ../../hl2sdk-ob -HL2SDK_CSS = ../../hl2sdk-css -HL2SDK_OB_VALVE = ../../hl2sdk-ob-valve -HL2SDK_L4D = ../../hl2sdk-l4d -HL2SDK_L4D2 = ../../hl2sdk-l4d2 -HL2SDK_CSGO = ../../hl2sdk-csgo -MMSOURCE = ../../mmsource-central - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreConfig.cpp \ - Database.cpp DebugReporter.cpp EventManager.cpp HalfLife2.cpp Logger.cpp \ - PlayerManager.cpp TimerSys.cpp UserMessages.cpp \ - sm_autonatives.cpp sm_srvcmds.cpp sm_stringutil.cpp sm_trie.cpp \ - sourcemm_api.cpp sourcemod.cpp MenuStyle_Base.cpp MenuStyle_Valve.cpp MenuManager.cpp \ - MenuStyle_Radio.cpp ChatTriggers.cpp ADTFactory.cpp MenuVoting.cpp \ - frame_hooks.cpp concmd_cleaner.cpp NextMap.cpp \ - NativeOwner.cpp logic_bridge.cpp ConsoleDetours.cpp -OBJECTS += smn_bitbuffer.cpp smn_console.cpp smn_core.cpp \ - smn_database.cpp smn_entities.cpp smn_events.cpp \ - smn_fakenatives.cpp smn_filesystem.cpp smn_halflife.cpp \ - smn_keyvalues.cpp smn_player.cpp \ - smn_usermsgs.cpp smn_menus.cpp smn_vector.cpp \ - smn_hudtext.cpp smn_nextmap.cpp -OBJECTS += ExtensionSys.cpp \ - ForwardSys.cpp \ - HandleSys.cpp \ - LibrarySys.cpp \ - PluginInfoDatabase.cpp \ - PluginSys.cpp \ - ShareSys.cpp \ - NativeInvoker.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false - -ifneq (,$(filter original orangebox css orangeboxvalve left4dead left4dead2 csgo,$(ENGINE))) - override ENGSET = true -endif - -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - BINARY = sourcemod.1.ep1.so -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE)/core - INCLUDE += -I$(HL2SDK)/public/game/server - BINARY = sourcemod.2.ep2.so -endif -ifeq "$(ENGINE)" "css" - HL2SDK = $(HL2SDK_CSS) - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=6 - METAMOD = $(MMSOURCE)/core - INCLUDE += -I$(HL2SDK)/public/game/server - BINARY = sourcemod.2.css.so -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=7 - METAMOD = $(MMSOURCE)/core - INCLUDE += -I$(HL2SDK)/public/game/server - BINARY = sourcemod.2.ep2v.so -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=8 - METAMOD = $(MMSOURCE)/core - INCLUDE += -I$(HL2SDK)/public/game/server - BINARY = sourcemod.2.l4d.so -endif -ifeq "$(ENGINE)" "left4dead2" - HL2SDK = $(HL2SDK_L4D2) - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=9 - METAMOD = $(MMSOURCE)/core - INCLUDE += -I$(HL2SDK)/public/game/server - BINARY = sourcemod.2.l4d2.so -endif -ifeq "$(ENGINE)" "csgo" - HL2SDK = $(HL2SDK_CSGO) - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=12 - METAMOD = $(MMSOURCE)/core - INCLUDE += -I$(HL2SDK)/public/game/server - BINARY = sourcemod.2.csgo.so -endif - -HL2PUB = $(HL2SDK)/public - -OS := $(shell uname -s) - -ifeq "$(OS)" "Darwin" - LIB_EXT = dylib - HL2LIB = $(HL2SDK)/lib/mac -else - LIB_EXT = so - ifeq "$(ENGINE)" "original" - HL2LIB = $(HL2SDK)/linux_sdk - else - HL2LIB = $(HL2SDK)/lib/linux - endif -endif - -ifneq (,$(filter original orangebox left4dead,$(ENGINE))) - LIB_SUFFIX = _i486.$(LIB_EXT) -else - LIB_PREFIX = lib - ifneq (,$(filter orangeboxvalve css,$(ENGINE))) - ifneq "$(OS)" "Darwin" - LIB_SUFFIX = _srv.$(LIB_EXT) - else - LIB_SUFFIX = .$(LIB_EXT) - endif - else - LIB_SUFFIX = .$(LIB_EXT) - endif -endif - -CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_BLOODYGOODTIME=4 -DSE_EYE=5 \ - -DSE_CSS=6 -DSE_ORANGEBOXVALVE=7 -DSE_LEFT4DEAD=8 -DSE_LEFT4DEAD2=9 -DSE_ALIENSWARM=10 \ - -DSE_PORTAL2=11 -DSE_CSGO=12 - -LINK += $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) \ - $(LIB_PREFIX)tier0$(LIB_SUFFIX) -static-libgcc - -ifeq "$(ENGINE)" "csgo" - LINK += $(HL2LIB)/interfaces_i486.a -endif - -INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \ - -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook \ - -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn - -CFLAGS += -D_LINUX -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \ - -Wno-uninitialized -Wno-unused -Wno-switch -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H \ - -DSM_DEFAULT_THREADER -m32 -DCOMPILER_GCC -CPPFLAGS += -Wno-non-virtual-dtor -Wno-overloaded-virtual -fno-threadsafe-statics -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug.$(ENGINE) - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release.$(ENGINE) - CFLAGS += $(C_OPT_FLAGS) -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) -OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -$(BIN_DIR)/%.o: %.c - $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR) - ln -sf $(HL2LIB)/$(LIB_PREFIX)vstdlib$(LIB_SUFFIX) - ln -sf $(HL2LIB)/$(LIB_PREFIX)tier0$(LIB_SUFFIX) - $(MAKE) -f Makefile sourcemod - -check: - if [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply one of the following values for ENGINE:"; \ - echo "csgo, left4dead2, left4dead, orangeboxvalve, css, orangebox, or original"; \ - exit 1; \ - fi - -sourcemod: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/core/MenuStyle_Base.cpp b/core/MenuStyle_Base.cpp index cda17be8..415029c1 100644 --- a/core/MenuStyle_Base.cpp +++ b/core/MenuStyle_Base.cpp @@ -338,7 +338,8 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press) #endif 0, PITCH_NORM, -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \ + || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 0, #endif &pos); diff --git a/core/MenuStyle_Base.h b/core/MenuStyle_Base.h index 78a98e54..a9afe7b6 100644 --- a/core/MenuStyle_Base.h +++ b/core/MenuStyle_Base.h @@ -48,19 +48,19 @@ public: style = 0; access = 0; } - CItem(ke::Moveable other) - : info(ke::Move(other->info)), - display(ke::Move(other->display)) + CItem(CItem &&other) + : info(ke::Move(other.info)), + display(ke::Move(other.display)) { - style = other->style; - access = other->access; + style = other.style; + access = other.access; } - CItem & operator =(ke::Moveable other) + CItem & operator =(CItem &&other) { - info = ke::Move(other->info); - display = ke::Move(other->display); - style = other->style; - access = other->access; + info = ke::Move(other.info); + display = ke::Move(other.display); + style = other.style; + access = other.access; return *this; } diff --git a/core/MenuStyle_Radio.cpp b/core/MenuStyle_Radio.cpp index 4d33e9ba..306defd5 100644 --- a/core/MenuStyle_Radio.cpp +++ b/core/MenuStyle_Radio.cpp @@ -83,6 +83,10 @@ void CRadioStyle::OnSourceModLevelChange(const char *mapName) } g_bRadioInit = true; + + // Always register the style. Use IsSupported() to check for validity before use. + g_Menus.AddStyle(this); + const char *msg = g_pGameConf->GetKeyValue("HudRadioMenuMsg"); if (!msg || msg[0] == '\0') { @@ -118,7 +122,6 @@ void CRadioStyle::OnSourceModLevelChange(const char *mapName) } } - g_Menus.AddStyle(this); g_Menus.SetDefaultStyle(this); g_UserMsgs.HookUserMessage(g_ShowMenuId, this, false); @@ -593,6 +596,7 @@ bool CRadioMenu::DisplayAtItem(int client, return false; } + AutoHandleRooter ahr(this->GetHandle()); return g_RadioMenuStyle.DoClientMenu(client, this, start_item, diff --git a/core/MenuStyle_Radio.h b/core/MenuStyle_Radio.h index b7a32741..90f6a59f 100644 --- a/core/MenuStyle_Radio.h +++ b/core/MenuStyle_Radio.h @@ -41,6 +41,8 @@ #include "sm_fastlink.h" #include #include +#include "logic/common_logic.h" +#include "AutoHandleRooter.h" using namespace SourceMod; diff --git a/core/MenuStyle_Valve.cpp b/core/MenuStyle_Valve.cpp index 97e551d9..24b261a1 100644 --- a/core/MenuStyle_Valve.cpp +++ b/core/MenuStyle_Valve.cpp @@ -408,6 +408,7 @@ bool CValveMenu::DisplayAtItem(int client, return false; } + AutoHandleRooter ahr(this->GetHandle()); return g_ValveMenuStyle.DoClientMenu(client, this, start_item, alt_handler ? alt_handler : m_pHandler, time); } diff --git a/core/MenuStyle_Valve.h b/core/MenuStyle_Valve.h index 60b86919..03fa1226 100644 --- a/core/MenuStyle_Valve.h +++ b/core/MenuStyle_Valve.h @@ -39,6 +39,8 @@ #include "KeyValues.h" #include "sm_fastlink.h" #include +#include "logic/common_logic.h" +#include "AutoHandleRooter.h" using namespace SourceMod; diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index c9b6e8ed..8c366f34 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -128,7 +128,7 @@ public: PlayerManager::PlayerManager() { m_AuthQueue = NULL; - m_FirstPass = false; + m_bServerActivated = false; m_maxClients = 0; m_SourceTVUserId = -1; @@ -148,6 +148,19 @@ PlayerManager::~PlayerManager() delete [] m_UserIdLookUp; } +void PlayerManager::OnSourceModStartup(bool late) +{ + /* Initialize all players */ + + m_PlayerCount = 0; + m_Players = new CPlayer[SM_MAXPLAYERS + 1]; + m_AuthQueue = new unsigned int[SM_MAXPLAYERS + 1]; + + memset(m_AuthQueue, 0, sizeof(unsigned int) * (SM_MAXPLAYERS + 1)); + + g_NumPlayersToAuth = &m_AuthQueue[0]; +} + void PlayerManager::OnSourceModAllInitialized() { SH_ADD_HOOK(IServerGameClients, ClientConnect, serverClients, SH_MEMBER(this, &PlayerManager::OnClientConnect), false); @@ -285,9 +298,6 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl static ConVar *replay_enable = icvar->FindVar("replay_enable"); #endif - // clientMax will not necessarily be correct here (such as on late SourceTV enable) - m_maxClients = gpGlobals->maxClients; - ICommandLine *commandLine = g_HL2.GetValveCommandLine(); m_bIsSourceTVActive = (tv_enable && tv_enable->GetBool() && (!commandLine || commandLine->FindParm("-nohltv") == 0)); m_bIsReplayActive = false; @@ -296,23 +306,8 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl #endif m_PlayersSinceActive = 0; - if (!m_FirstPass) - { - /* Initialize all players */ - - m_PlayerCount = 0; - m_Players = new CPlayer[SM_MAXPLAYERS + 1]; - m_AuthQueue = new unsigned int[SM_MAXPLAYERS + 1]; - m_FirstPass = true; - - memset(m_AuthQueue, 0, sizeof(unsigned int) * (SM_MAXPLAYERS + 1)); - - g_NumPlayersToAuth = &m_AuthQueue[0]; - } - - scripts->SyncMaxClients(m_maxClients); - g_OnMapStarted = true; + m_bServerActivated = true; #if SOURCE_ENGINE == SE_DOTA extsys->CallOnCoreMapStart(gpGlobals->pEdicts, gpGlobals->maxEntities, gpGlobals->maxClients); @@ -344,7 +339,7 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl bool PlayerManager::IsServerActivated() { - return m_FirstPass; + return m_bServerActivated; } bool PlayerManager::CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id) @@ -1826,11 +1821,6 @@ void PlayerManager::OnSourceModMaxPlayersChanged( int newvalue ) void PlayerManager::MaxPlayersChanged( int newvalue /*= -1*/ ) { - if (!m_FirstPass) - { - return; - } - if (newvalue == -1) { newvalue = gpGlobals->maxClients; @@ -2003,6 +1993,13 @@ void CPlayer::UpdateAuthIds() #else authstr = engine->GetPlayerNetworkIDString(m_pEdict); #endif + + if (!authstr) + { + // engine doesn't have the client's auth string just yet, we can't do anything + return; + } + if (m_AuthID.compare(authstr) == 0) { return; diff --git a/core/PlayerManager.h b/core/PlayerManager.h index 3f78c9f8..d580e848 100644 --- a/core/PlayerManager.h +++ b/core/PlayerManager.h @@ -154,6 +154,7 @@ public: PlayerManager(); ~PlayerManager(); public: //SMGlobalClass + void OnSourceModStartup(bool late) override; void OnSourceModAllInitialized(); void OnSourceModShutdown(); void OnSourceModLevelEnd(); @@ -250,7 +251,7 @@ private: int m_maxClients; int m_PlayerCount; int m_PlayersSinceActive; - bool m_FirstPass; + bool m_bServerActivated; unsigned int *m_AuthQueue; String m_PassInfoVar; bool m_QueryLang; diff --git a/core/logic/AMBuilder b/core/logic/AMBuilder index ba3d064a..af59296f 100644 --- a/core/logic/AMBuilder +++ b/core/logic/AMBuilder @@ -5,8 +5,8 @@ binary = SM.Library(builder, 'sourcemod.logic') binary.compiler.cxxincludes += [ os.path.join(builder.sourcePath, 'core', 'logic'), os.path.join(builder.sourcePath, 'public'), - os.path.join(builder.sourcePath, 'public', 'sourcepawn'), - os.path.join(builder.sourcePath, 'public', 'amtl'), + os.path.join(builder.sourcePath, 'sourcepawn', 'include'), + os.path.join(builder.sourcePath, 'public', 'amtl', 'include'), os.path.join(SM.mms_root, 'core', 'sourcehook') ] binary.compiler.defines += [ @@ -62,7 +62,6 @@ binary.sources += [ 'PluginSys.cpp', 'HandleSys.cpp', 'NativeOwner.cpp', - 'NativeInvoker.cpp', 'ExtensionSys.cpp', 'DebugReporter.cpp', 'Database.cpp', diff --git a/core/logic/AdminCache.cpp b/core/logic/AdminCache.cpp index e88a722a..d3833c00 100644 --- a/core/logic/AdminCache.cpp +++ b/core/logic/AdminCache.cpp @@ -39,15 +39,16 @@ #include "AdminCache.h" #include "Translator.h" #include "common_logic.h" +#include "stringutil.h" #define LEVEL_STATE_NONE 0 #define LEVEL_STATE_LEVELS 1 #define LEVEL_STATE_FLAGS 2 AdminCache g_Admins; -char g_ReverseFlags[26]; +char g_ReverseFlags[AdminFlags_TOTAL]; AdminFlag g_FlagLetters[26]; -bool g_FlagSet[26]; +bool g_FlagCharSet[26]; /* Default flags */ AdminFlag g_DefaultFlags[26] = @@ -71,9 +72,9 @@ public: memcpy(g_FlagLetters, g_DefaultFlags, sizeof(AdminFlag) * 26); for (unsigned int i=0; i<20; i++) { - g_FlagSet[i] = true; + g_FlagCharSet[i] = true; } - g_FlagSet[25] = true; + g_FlagCharSet[25] = true; } } private: @@ -103,7 +104,7 @@ private: { m_LevelState = LEVEL_STATE_NONE; m_IgnoreLevel = 0; - memset(g_FlagSet, 0, sizeof(g_FlagSet)); + memset(g_FlagCharSet, 0, sizeof(g_FlagCharSet)); } SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name) { @@ -163,7 +164,7 @@ private: return SMCResult_Continue; } - g_FlagSet[c] = true; + g_FlagCharSet[c] = true; return SMCResult_Continue; } @@ -981,7 +982,6 @@ void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild) { List::iterator iter; IAdminListener *pListener; - cell_t result; if (part == AdminCache_Overrides) { @@ -995,7 +995,7 @@ void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild) pListener->OnRebuildOverrideCache(); } m_pCacheFwd->PushCell(part); - m_pCacheFwd->Execute(&result); + m_pCacheFwd->Execute(); } } else if (part == AdminCache_Groups || part == AdminCache_Admins) { if (part == AdminCache_Groups) @@ -1009,7 +1009,7 @@ void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild) pListener->OnRebuildGroupCache(); } m_pCacheFwd->PushCell(part); - m_pCacheFwd->Execute(&result); + m_pCacheFwd->Execute(); } } InvalidateAdminCache(true); @@ -1021,7 +1021,7 @@ void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild) pListener->OnRebuildAdminCache((part == AdminCache_Groups)); } m_pCacheFwd->PushCell(AdminCache_Admins); - m_pCacheFwd->Execute(&result); + m_pCacheFwd->Execute(); playerhelpers->RecheckAnyAdmins(); } } @@ -1063,22 +1063,29 @@ bool AdminCache::GetMethodIndex(const char *name, unsigned int *_index) bool AdminCache::GetUnifiedSteamIdentity(const char *ident, char *out, size_t maxlen) { int len = strlen(ident); - /* If the id was a steam id strip off the STEAM_*: part */ - if (len >= 11 && !strncmp(ident, "STEAM_", 6) && ident[8] != '_') + if (!strcmp(ident, "BOT")) { - // non-bot/lan Steam2 Id + // Bots + strncopy(out, ident, maxlen); + return true; + } + else if (len >= 11 && !strncmp(ident, "STEAM_", 6) && ident[8] != '_') + { + // non-bot/lan Steam2 Id, strip off the STEAM_* part snprintf(out, maxlen, "%s", &ident[8]); return true; } else if (len >= 7 && !strncmp(ident, "[U:", 3) && ident[len-1] == ']') { - // Steam3 Id + // Steam3 Id, replicate the Steam2 Post-"STEAM_" part uint32_t accountId = strtoul(&ident[5], nullptr, 10); snprintf(out, maxlen, "%u:%u", accountId & 1, accountId >> 1); return true; } else { + // 64-bit CSteamID, replicate the Steam2 Post-"STEAM_" part + // some constants from steamclientpublic.h static const uint32_t k_EAccountTypeIndividual = 1; static const int k_EUniverseInvalid = 0; @@ -1577,7 +1584,7 @@ bool AdminCache::FindFlag(char c, AdminFlag *pAdmFlag) { if (c < 'a' || c > 'z' - || !g_FlagSet[(unsigned)c - (unsigned)'a']) + || !g_FlagCharSet[(unsigned)c - (unsigned)'a']) { return false; } @@ -1592,17 +1599,13 @@ bool AdminCache::FindFlag(char c, AdminFlag *pAdmFlag) bool AdminCache::FindFlagChar(AdminFlag flag, char *c) { - if (!g_FlagSet[flag]) - { - return false; - } - + char flagchar = g_ReverseFlags[flag]; if (c) { - *c = g_ReverseFlags[flag]; + *c = flagchar; } - return true; + return flagchar != '?'; } FlagBits AdminCache::ReadFlagString(const char *flags, const char **end) diff --git a/core/logic/DebugReporter.cpp b/core/logic/DebugReporter.cpp index ef5863ba..4b1199f1 100644 --- a/core/logic/DebugReporter.cpp +++ b/core/logic/DebugReporter.cpp @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourceMod * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. @@ -132,51 +132,6 @@ void DebugReport::GenerateCodeError(IPluginContext *pContext, uint32_t code_addr } } -void DebugReport::OnContextExecuteError(IPluginContext *ctx, IContextTrace *error) -{ - const char *lastname; - const char *plname = pluginsys->FindPluginByContext(ctx->GetContext())->GetFilename(); - int n_err = error->GetErrorCode(); - - if (n_err != SP_ERROR_NATIVE) - { - g_Logger.LogError("[SM] Plugin encountered error %d: %s", - n_err, - error->GetErrorString()); - } - - if ((lastname=error->GetLastNative(NULL)) != NULL) - { - const char *custerr; - if ((custerr=error->GetCustomErrorString()) != NULL) - { - g_Logger.LogError("[SM] Native \"%s\" reported: %s", lastname, custerr); - } else { - g_Logger.LogError("[SM] Native \"%s\" encountered a generic error.", lastname); - } - } - - if (!error->DebugInfoAvailable()) - { - g_Logger.LogError("[SM] Debug mode is not enabled for \"%s\"", plname); - g_Logger.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on", - _GetPluginIndex(ctx)); - return; - } - - CallStackInfo stk_info; - int i = 0; - g_Logger.LogError("[SM] Displaying call stack trace for plugin \"%s\":", plname); - while (error->GetTraceInfo(&stk_info)) - { - g_Logger.LogError("[SM] [%d] Line %d, %s::%s()", - i++, - stk_info.line, - stk_info.filename, - stk_info.function); - } -} - int DebugReport::_GetPluginIndex(IPluginContext *ctx) { int id = 1; @@ -199,3 +154,46 @@ int DebugReport::_GetPluginIndex(IPluginContext *ctx) return pluginsys->GetPluginCount() + 1; } +void DebugReport::ReportError(const IErrorReport &report, IFrameIterator &iter) +{ + // Find the nearest plugin to blame. + const char *blame = nullptr; + for (; !iter.Done(); iter.Next()) { + if (iter.IsScriptedFrame()) { + IPlugin *plugin = pluginsys->FindPluginByContext(iter.Context()->GetContext()); + if (plugin) + blame = plugin->GetFilename(); + else + blame = iter.Context()->GetRuntime()->GetFilename(); + break; + } + } + + iter.Reset(); + + g_Logger.LogError("[SM] Exception reported: %s", report.Message()); + if (blame) + g_Logger.LogError("[SM] Blaming plugin: %s", blame); + g_Logger.LogError("[SM] Call stack trace:"); + + for (int index = 0; !iter.Done(); iter.Next(), index++) { + const char *fn = iter.FunctionName(); + if (!fn) + fn = ""; + + if (iter.IsNativeFrame()) { + g_Logger.LogError("[SM] [%d] %s", index, fn); + continue; + } + if (iter.IsScriptedFrame()) { + const char *file = iter.FilePath(); + if (!file) + file = ""; + g_Logger.LogError("[SM] [%d] Line %d, %s::%s()", + index, + iter.LineNumber(), + file, + fn); + } + } +} diff --git a/core/logic/DebugReporter.h b/core/logic/DebugReporter.h index ac4d97a9..e43b3a08 100644 --- a/core/logic/DebugReporter.h +++ b/core/logic/DebugReporter.h @@ -42,7 +42,7 @@ class DebugReport : public: // SMGlobalClass void OnSourceModAllInitialized(); public: // IDebugListener - void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error); + void ReportError(const IErrorReport &report, IFrameIterator &iter); void OnDebugSpew(const char *msg, ...); public: void GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...); diff --git a/core/logic/HandleSys.h b/core/logic/HandleSys.h index bf7094ef..670f5602 100644 --- a/core/logic/HandleSys.h +++ b/core/logic/HandleSys.h @@ -38,7 +38,7 @@ #include #include "common_logic.h" -#define HANDLESYS_MAX_HANDLES (1<<14) +#define HANDLESYS_MAX_HANDLES (1<<15) #define HANDLESYS_MAX_TYPES (1<<9) #define HANDLESYS_MAX_SUBTYPES 0xF #define HANDLESYS_SUBTYPE_MASK 0xF diff --git a/core/logic/Makefile b/core/logic/Makefile deleted file mode 100644 index a293f8f7..00000000 --- a/core/logic/Makefile +++ /dev/null @@ -1,108 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -MMSOURCE17 = ../../../mmsource-1.7 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -BINARY = sourcemod.logic.so - -OBJECTS = \ - common_logic.cpp \ - smn_adt_array.cpp \ - smn_sorting.cpp \ - smn_maplists.cpp \ - smn_adt_stack.cpp \ - thread/ThreadWorker.cpp \ - thread/BaseWorker.cpp \ - thread/PosixThreads.cpp \ - ThreadSupport.cpp \ - smn_float.cpp \ - TextParsers.cpp \ - smn_textparse.cpp \ - smn_adt_trie.cpp \ - Profiler.cpp \ - smn_functions.cpp \ - sm_crc32.cpp \ - smn_timers.cpp \ - MemoryUtils.cpp \ - smn_admin.cpp \ - smn_banning.cpp \ - stringutil.cpp \ - Translator.cpp \ - PhraseCollection.cpp \ - smn_lang.cpp \ - smn_string.cpp \ - smn_handles.cpp \ - smn_datapacks.cpp \ - smn_gameconfigs.cpp \ - GameConfigs.cpp \ - smn_players.cpp \ - smn_profiler.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -LINK += -lpthread -static-libgcc - -INCLUDE += -I. -I$(MMSOURCE17)/core/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \ - -Wno-uninitialized -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -DSM_DEFAULT_THREADER -m32 \ - -DSM_LOGIC -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) -OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -$(BIN_DIR)/%.o: %.c - $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< - -all: - mkdir -p $(BIN_DIR)/thread - $(MAKE) -f Makefile sourcemod - -sourcemod: $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/thread/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/core/logic/NativeInvoker.cpp b/core/logic/NativeInvoker.cpp deleted file mode 100644 index 9698bd7a..00000000 --- a/core/logic/NativeInvoker.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/** - * vim: set ts=4 sw=4 tw=99 noet : - * ============================================================================= - * SourcePawn - * Copyright (C) 2004-2009 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#include "NativeInvoker.h" -#include "ShareSys.h" - -NativeInterface g_NInvoke; - -NativeInvoker::NativeInvoker() -{ -} - -NativeInvoker::~NativeInvoker() -{ -} - -const char *NativeInterface::GetInterfaceName() -{ - return SMINTERFACE_NINVOKE_NAME; -} - -unsigned int NativeInterface::GetInterfaceVersion() -{ - return SMINTERFACE_NINVOKE_VERSION; -} - -void NativeInterface::OnSourceModAllInitialized() -{ - sharesys->AddInterface(NULL, &g_NInvoke); -} - -IPluginRuntime *NativeInterface::CreateRuntime(const char *name, size_t bytes) -{ - return g_pSourcePawn2->CreateEmptyRuntime(name, bytes); -} - -INativeInvoker *NativeInterface::CreateInvoker() -{ - return new NativeInvoker(); -} - -bool NativeInvoker::Start(IPluginContext *pContext, const char *name) -{ - ke::Ref entry = g_ShareSys.FindNative(name); - if (!entry) - return false; - - if (!entry->owner) - return false; - - native_ = entry->func(); - context_ = pContext; - - m_curparam = 0; - m_errorstate = SP_ERROR_NONE; - - return true; -} - -cell_t NativeInvoker::PushCell(cell_t cell) -{ - if (m_curparam >= SP_MAX_EXEC_PARAMS) - { - return SetError(SP_ERROR_PARAMS_MAX); - } - - m_info[m_curparam].marked = false; - m_params[m_curparam] = cell; - m_curparam++; - - return SP_ERROR_NONE; -} - -int NativeInvoker::PushCellByRef(cell_t *cell, int flags) -{ - return PushArray(cell, 1, flags); -} - -int NativeInvoker::PushFloat(float number) -{ - cell_t val = *(cell_t *)&number; - - return PushCell(val); -} - -int NativeInvoker::PushFloatByRef(float *number, int flags) -{ - return PushCellByRef((cell_t *)number, flags); -} - -int NativeInvoker::PushArray(cell_t *inarray, unsigned int cells, int copyback) -{ - if (m_curparam >= SP_MAX_EXEC_PARAMS) - { - return SetError(SP_ERROR_PARAMS_MAX); - } - - ParamInfo *info = &m_info[m_curparam]; - - info->flags = inarray ? copyback : 0; - info->marked = true; - info->size = cells; - info->str.is_sz = false; - info->orig_addr = inarray; - - m_curparam++; - - return SP_ERROR_NONE; -} - -int NativeInvoker::PushString(const char *string) -{ - return _PushString(string, SM_PARAM_STRING_COPY, 0, strlen(string)+1); -} - -int NativeInvoker::PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags) -{ - return _PushString(buffer, sz_flags, cp_flags, length); -} - -int NativeInvoker::_PushString(const char *string, int sz_flags, int cp_flags, size_t len) -{ - if (m_curparam >= SP_MAX_EXEC_PARAMS) - { - return SetError(SP_ERROR_PARAMS_MAX); - } - - ParamInfo *info = &m_info[m_curparam]; - - info->marked = true; - info->orig_addr = (cell_t *)string; - info->flags = cp_flags; - info->size = len; - info->str.sz_flags = sz_flags; - info->str.is_sz = true; - - m_curparam++; - - return SP_ERROR_NONE; -} - -void NativeInvoker::Cancel() -{ - if (context_ == NULL) - return; - - m_errorstate = SP_ERROR_NONE; - m_curparam = 0; - context_ = NULL; - native_ = NULL; -} - -int NativeInvoker::SetError(int err) -{ - m_errorstate = err; - return err; -} - -int NativeInvoker::Invoke(cell_t *result) -{ - int err = SP_ERROR_NONE; - - if (context_ == NULL) - return SP_ERROR_INVALID_NATIVE; - - if (m_errorstate != SP_ERROR_NONE) - { - err = m_errorstate; - Cancel(); - return err; - } - - cell_t tresult; - - if (result == NULL) - { - result = &tresult; - } - - //This is for re-entrancy! - IPluginContext *ctx = context_; - cell_t _temp_params[SP_MAX_EXEC_PARAMS + 1]; - cell_t *temp_params = &_temp_params[1]; - ParamInfo temp_info[SP_MAX_EXEC_PARAMS]; - unsigned int numparams = m_curparam; - unsigned int i; - bool docopies = true; - - if (numparams) - { - //Save the info locally, then reset it for re-entrant calls. - memcpy(temp_info, m_info, numparams * sizeof(ParamInfo)); - } - m_curparam = 0; - context_ = NULL; - - /* Initialize 0th parameter */ - _temp_params[0] = numparams; - - /* Browse the parameters and build arrays */ - for (i = 0; i < numparams; i++) - { - /* Is this marked as an array? */ - if (temp_info[i].marked) - { - if (!temp_info[i].str.is_sz) - { - /* Allocate a normal/generic array */ - if ((err = ctx->HeapAlloc(temp_info[i].size, - &temp_info[i].local_addr, - &temp_info[i].phys_addr)) - != SP_ERROR_NONE) - { - break; - } - if (temp_info[i].orig_addr) - { - memcpy(temp_info[i].phys_addr, temp_info[i].orig_addr, sizeof(cell_t) * temp_info[i].size); - } - } - else - { - /* Calculate cells required for the string */ - size_t cells = (temp_info[i].size + sizeof(cell_t) - 1) / sizeof(cell_t); - - /* Allocate the buffer */ - if ((err = ctx->HeapAlloc(cells, - &temp_info[i].local_addr, - &temp_info[i].phys_addr)) - != SP_ERROR_NONE) - { - break; - } - /* Copy original string if necessary */ - if ((temp_info[i].str.sz_flags & SM_PARAM_STRING_COPY) && (temp_info[i].orig_addr != NULL)) - { - /* Cut off UTF-8 properly */ - if (temp_info[i].str.sz_flags & SM_PARAM_STRING_UTF8) - { - if ((err = ctx->StringToLocalUTF8(temp_info[i].local_addr, - temp_info[i].size, - (const char *)temp_info[i].orig_addr, - NULL)) - != SP_ERROR_NONE) - { - break; - } - } - /* Copy a binary blob */ - else if (temp_info[i].str.sz_flags & SM_PARAM_STRING_BINARY) - { - memmove(temp_info[i].phys_addr, temp_info[i].orig_addr, temp_info[i].size); - } - /* Copy ASCII characters */ - else - { - if ((err = ctx->StringToLocal(temp_info[i].local_addr, - temp_info[i].size, - (const char *)temp_info[i].orig_addr)) - != SP_ERROR_NONE) - { - break; - } - } - } - } /* End array/string calculation */ - /* Update the pushed parameter with the byref local address */ - temp_params[i] = temp_info[i].local_addr; - } - else - { - /* Just copy the value normally */ - temp_params[i] = m_params[i]; - } - } - - /* Make the call if we can */ - if (err == SP_ERROR_NONE) - { - *result = native_(ctx, _temp_params); - if (ctx->GetLastNativeError() != SP_ERROR_NONE) - { - docopies = false; - ctx->ClearLastNativeError(); - } - } - else - { - docopies = false; - } - - /* i should be equal to the last valid parameter + 1 */ - while (i--) - { - if (!temp_info[i].marked) - { - continue; - } - - if (docopies && (temp_info[i].flags & SM_PARAM_COPYBACK)) - { - if (temp_info[i].orig_addr) - { - if (temp_info[i].str.is_sz) - { - memcpy(temp_info[i].orig_addr, temp_info[i].phys_addr, temp_info[i].size); - - } - else - { - if (temp_info[i].size == 1) - { - *temp_info[i].orig_addr = *(temp_info[i].phys_addr); - } - else - { - memcpy(temp_info[i].orig_addr, - temp_info[i].phys_addr, - temp_info[i].size * sizeof(cell_t)); - } - } - } - } - - if ((err = ctx->HeapPop(temp_info[i].local_addr)) != SP_ERROR_NONE) - { - return err; - } - } - - return err; -} diff --git a/core/logic/NativeInvoker.h b/core/logic/NativeInvoker.h deleted file mode 100644 index 6e673245..00000000 --- a/core/logic/NativeInvoker.h +++ /dev/null @@ -1,102 +0,0 @@ -/** - * vim: set ts=4 : - * ============================================================================= - * SourceMod - * Copyright (C) 2004-2009 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_ -#define _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_ - -#include -#include -#include "common_logic.h" - -using namespace SourceMod; -using namespace SourcePawn; - -struct ParamInfo -{ - int flags; /* Copy-back flags */ - bool marked; /* Whether this is marked as being used */ - cell_t local_addr; /* Local address to free */ - cell_t *phys_addr; /* Physical address of our copy */ - cell_t *orig_addr; /* Original address to copy back to */ - ucell_t size; /* Size of array in bytes */ - struct - { - bool is_sz; /* is a string */ - int sz_flags; /* has sz flags */ - } str; -}; - -class NativeInvoker : public INativeInvoker -{ -public: - NativeInvoker(); - ~NativeInvoker(); -public: /* ICallable */ - int PushCell(cell_t cell); - int PushCellByRef(cell_t *cell, int flags=SM_PARAM_COPYBACK); - int PushFloat(float number); - int PushFloatByRef(float *number, int flags=SM_PARAM_COPYBACK); - int PushArray(cell_t *inarray, unsigned int cells, int flags=0); - int PushString(const char *string); - int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags); - void Cancel(); -public: /* INativeInvoker */ - bool Start(IPluginContext *pContext, const char *name); - int Invoke(cell_t *result); -private: - int _PushString(const char *string, int sz_flags, int cp_flags, size_t len); - int SetError(int err); -private: - IPluginContext *context_; - SPVM_NATIVE_FUNC native_; - cell_t m_params[SP_MAX_EXEC_PARAMS]; - ParamInfo m_info[SP_MAX_EXEC_PARAMS]; - unsigned int m_curparam; - int m_errorstate; -}; - -class NativeInterface : - public INativeInterface, - public SMGlobalClass -{ -public: /* SMGlobalClass */ - void OnSourceModAllInitialized(); -public: /* SMInterface */ - unsigned int GetInterfaceVersion(); - const char *GetInterfaceName(); -public: /* INativeInvoker */ - IPluginRuntime *CreateRuntime(const char *name, size_t bytes); - INativeInvoker *CreateInvoker(); -}; - -extern NativeInterface g_NInvoke; - -#endif /* _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_ */ diff --git a/core/logic/NativeOwner.cpp b/core/logic/NativeOwner.cpp index bb62f837..e6adcb2e 100644 --- a/core/logic/NativeOwner.cpp +++ b/core/logic/NativeOwner.cpp @@ -84,11 +84,11 @@ void CNativeOwner::UnbindWeakRef(const WeakNative &ref) IPluginContext *pContext; pContext = ref.pl->GetBaseContext(); - if ((pContext->GetNativeByIndex(ref.idx, &native)) == SP_ERROR_NONE) - { - native->status = SP_NATIVE_UNBOUND; - native->pfn = NULL; - } + pContext->GetRuntime()->UpdateNativeBinding( + ref.idx, + nullptr, + 0, + nullptr); } void CNativeOwner::DropEverything() diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index ae7935f1..bc4949ef 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -646,11 +646,7 @@ void CPlugin::DependencyDropped(CPlugin *pOwner) if (m_pRuntime->FindNativeByName(entry->name(), &idx) != SP_ERROR_NONE) continue; - sp_native_t *native; - m_pRuntime->GetNativeByIndex(idx, &native); - - native->pfn = NULL; - native->status = SP_NATIVE_UNBOUND; + m_pRuntime->UpdateNativeBinding(idx, nullptr, 0, nullptr); unbound++; } @@ -931,44 +927,23 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **aResult, const char *path, bool de pPlugin->m_type = PluginType_MapUpdated; - ICompilation *co = NULL; - if (pPlugin->m_status == Plugin_Uncompiled) - { - co = g_pSourcePawn2->StartCompilation(); - } - - /* Do the actual compiling */ - if (co != NULL) { char fullpath[PLATFORM_MAX_PATH]; g_pSM->BuildPath(Path_SM, fullpath, sizeof(fullpath), "plugins/%s", pPlugin->m_filename); - pPlugin->m_pRuntime = g_pSourcePawn2->LoadPlugin(co, fullpath, &err); - if (pPlugin->m_pRuntime == NULL) - { + char loadmsg[255]; + pPlugin->m_pRuntime = g_pSourcePawn2->LoadBinaryFromFile(fullpath, loadmsg, sizeof(loadmsg)); + if (!pPlugin->m_pRuntime) { if (error) - { - smcore.Format(error, - maxlength, - "Unable to load plugin (error %d: %s)", - err, - g_pSourcePawn2->GetErrorString(err)); - } + smcore.Format(error, maxlength, "Unable to load plugin (%s)", loadmsg); pPlugin->m_status = Plugin_BadLoad; - } - else - { - if (pPlugin->UpdateInfo()) - { + } else { + if (pPlugin->UpdateInfo()) { pPlugin->m_status = Plugin_Created; - } - else - { + } else { if (error) - { smcore.Format(error, maxlength, "%s", pPlugin->m_errormsg); - } } } } @@ -1200,13 +1175,9 @@ bool CPluginManager::FindOrRequirePluginDeps(CPlugin *pPlugin, char *error, size if ((pFunc=pBase->GetFunctionByName(buffer))) { cell_t res; - pFunc->Execute(&res); - if (pPlugin->GetBaseContext()->GetLastNativeError() != SP_ERROR_NONE) - { + if (pFunc->Execute(&res) != SP_ERROR_NONE) { if (error) - { smcore.Format(error, maxlength, "Fatal error during initializing plugin load"); - } return false; } } @@ -1328,13 +1299,9 @@ bool CPluginManager::LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass if ((pFunc = pBase->GetFunctionByName(buffer)) != NULL) { cell_t res; - pFunc->Execute(&res); - if (pPlugin->GetBaseContext()->GetLastNativeError() != SP_ERROR_NONE) - { + if (pFunc->Execute(&res) != SP_ERROR_NONE) { if (error) - { smcore.Format(error, maxlength, "Fatal error during plugin initialization (ext req)"); - } return false; } } @@ -1365,16 +1332,14 @@ bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxleng /* Find any unbound natives. Right now, these are not allowed. */ IPluginContext *pContext = pPlugin->GetBaseContext(); uint32_t num = pContext->GetNativesNum(); - sp_native_t *native; for (unsigned int i=0; iGetNativeByIndex(i, &native) != SP_ERROR_NONE) - { + const sp_native_t *native = pContext->GetRuntime()->GetNative(i); + if (!native) break; - } - if (native->status == SP_NATIVE_UNBOUND - && native->name[0] != '@' - && !(native->flags & SP_NTVFLAG_OPTIONAL)) + if (native->status == SP_NATIVE_UNBOUND && + native->name[0] != '@' && + !(native->flags & SP_NTVFLAG_OPTIONAL)) { if (error) { @@ -1486,16 +1451,14 @@ void CPluginManager::TryRefreshDependencies(CPlugin *pPlugin) */ IPluginContext *pContext = pPlugin->GetBaseContext(); uint32_t num = pContext->GetNativesNum(); - sp_native_t *native; for (unsigned int i=0; iGetNativeByIndex(i, &native) != SP_ERROR_NONE) - { + const sp_native_t *native = pContext->GetRuntime()->GetNative(i); + if (!native) break; - } - if (native->status == SP_NATIVE_UNBOUND - && native->name[0] != '@' - && !(native->flags & SP_NTVFLAG_OPTIONAL)) + if (native->status == SP_NATIVE_UNBOUND && + native->name[0] != '@' && + !(native->flags & SP_NTVFLAG_OPTIONAL)) { pPlugin->SetErrorState(Plugin_Error, "Native not found: %s", native->name); return; @@ -1547,7 +1510,7 @@ bool CPluginManager::UnloadPlugin(IPlugin *plugin) List::iterator iter; IPluginsListener *pListener; - if (pPlugin->GetStatus() <= Plugin_Error) + if (pPlugin->GetStatus() <= Plugin_Error || pPlugin->GetStatus() == Plugin_Failed) { /* Notify plugin */ pPlugin->Call_OnPluginEnd(); @@ -2312,6 +2275,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const CCommand &c } else if (strcmp(cmd, "refresh") == 0) { + RefreshAll(); smcore.DoGlobalPluginLoads(); rootmenu->ConsolePrint("[SM] The plugin list has been refreshed and reloaded."); return; diff --git a/core/logic/ShareSys.cpp b/core/logic/ShareSys.cpp index ddde22a5..16067b43 100644 --- a/core/logic/ShareSys.cpp +++ b/core/logic/ShareSys.cpp @@ -271,7 +271,6 @@ PassRef ShareSystem::FindNative(const char *name) void ShareSystem::BindNativesToPlugin(CPlugin *pPlugin, bool bCoreOnly) { - sp_native_t *native; uint32_t i, native_count; IPluginContext *pContext; @@ -284,7 +283,8 @@ void ShareSystem::BindNativesToPlugin(CPlugin *pPlugin, bool bCoreOnly) native_count = pContext->GetNativesNum(); for (i = 0; i < native_count; i++) { - if (pContext->GetNativeByIndex(i, &native) != SP_ERROR_NONE) + const sp_native_t *native = pContext->GetRuntime()->GetNative(i); + if (!native) continue; // If we're already bound, no need to do anything else. @@ -314,8 +314,8 @@ void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin, const Ref &entry) if (pContext->FindNativeByName(entry->name(), &i) != SP_ERROR_NONE) return; - sp_native_t *native; - if (pContext->GetNativeByIndex(i, &native) != SP_ERROR_NONE) + const sp_native_t *native = pContext->GetRuntime()->GetNative(i); + if (!native) return; if (native->status == SP_NATIVE_BOUND) @@ -324,18 +324,15 @@ void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin, const Ref &entry) BindNativeToPlugin(pPlugin, native, i, entry); } -void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin, sp_native_t *native, uint32_t index, +void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin, const sp_native_t *native, uint32_t index, const Ref &pEntry) { - /* Mark as bound... we do the rest next. */ - native->status = SP_NATIVE_BOUND; - native->pfn = pEntry->func(); - + uint32_t flags = 0; if (pEntry->fake) { /* This native is not necessarily optional, but we don't guarantee * that its address is long-lived. */ - native->flags |= SP_NTVFLAG_EPHEMERAL; + flags |= SP_NTVFLAG_EPHEMERAL; } /* We don't bother with dependency crap if the owner is Core. */ @@ -345,10 +342,9 @@ void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin, sp_native_t *native, uint if ((native->flags & SP_NTVFLAG_OPTIONAL) == SP_NTVFLAG_OPTIONAL) { /* Only add if there is a valid owner. */ - if (pEntry->owner) - pEntry->owner->AddWeakRef(WeakNative(pPlugin, index)); - else - native->status = SP_NATIVE_UNBOUND; + if (!pEntry->owner) + return; + pEntry->owner->AddWeakRef(WeakNative(pPlugin, index)); } /* Otherwise, we're a strong dependent and not a weak one */ else @@ -367,6 +363,12 @@ void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin, sp_native_t *native, uint } } } + + pPlugin->GetRuntime()->UpdateNativeBinding( + index, + pEntry->func(), + flags, + nullptr); } PassRef ShareSystem::AddNativeToCache(CNativeOwner *pOwner, const sp_nativeinfo_t *ntv) @@ -468,9 +470,7 @@ FeatureStatus ShareSystem::TestNative(IPluginRuntime *pRuntime, const char *name if (pRuntime->FindNativeByName(name, &index) == SP_ERROR_NONE) { - sp_native_t *native; - if (pRuntime->GetNativeByIndex(index, &native) == SP_ERROR_NONE) - { + if (const sp_native_t *native = pRuntime->GetNative(index)) { if (native->status == SP_NATIVE_BOUND) return FeatureStatus_Available; else diff --git a/core/logic/ShareSys.h b/core/logic/ShareSys.h index b9cc1aec..456e2c59 100644 --- a/core/logic/ShareSys.h +++ b/core/logic/ShareSys.h @@ -126,7 +126,7 @@ public: private: ke::PassRef AddNativeToCache(CNativeOwner *pOwner, const sp_nativeinfo_t *ntv); void ClearNativeFromCache(CNativeOwner *pOwner, const char *name); - void BindNativeToPlugin(CPlugin *pPlugin, sp_native_t *ntv, uint32_t index, const ke::Ref &pEntry); + void BindNativeToPlugin(CPlugin *pPlugin, const sp_native_t *ntv, uint32_t index, const ke::Ref &pEntry); private: typedef NameHashSet, Native> NativeCache; diff --git a/core/logic/msvc10/logic.sln b/core/logic/msvc10/logic.sln deleted file mode 100644 index c399481e..00000000 --- a/core/logic/msvc10/logic.sln +++ /dev/null @@ -1,19 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logic", "logic.vcxproj", "{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/core/logic/msvc10/logic.vcxproj b/core/logic/msvc10/logic.vcxproj deleted file mode 100644 index 869f548e..00000000 --- a/core/logic/msvc10/logic.vcxproj +++ /dev/null @@ -1,186 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7} - jitx86 - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - sourcemod.logic - sourcemod.logic - - - - Disabled - ..;$(MMSOURCE19)\core\sourcehook;..\..\..\public;..\..\..\public\sourcepawn;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SM_DEFAULT_THREADER;SM_LOGIC;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - ..\..\..\public - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - Speed - ..;$(MMSOURCE19)\core\sourcehook;..\..\..\public;..\..\..\public\sourcepawn;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SM_LOGIC;SM_DEFAULT_THREADER;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - ..\..\..\public - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/core/logic/msvc10/logic.vcxproj.filters b/core/logic/msvc10/logic.vcxproj.filters deleted file mode 100644 index ab1d9776..00000000 --- a/core/logic/msvc10/logic.vcxproj.filters +++ /dev/null @@ -1,231 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {67c1ebce-c1f8-4d2c-9ef4-33f0ef6343e9} - - - {c6e2ebb3-4869-4453-9b83-e49f70cb8a05} - - - {e6d8a9af-1c1b-4f0c-ae06-a9ebd5cd32e4} - - - {126462f2-e517-4854-8a94-759e56787536} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Threads\Source Files - - - Threads\Source Files - - - Threads\Source Files - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Source Files - - - Natives - - - Natives - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Threads\Header Files - - - Threads\Header Files - - - Threads\Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/core/logic/msvc9/logic.sln b/core/logic/msvc9/logic.sln deleted file mode 100755 index 1977332d..00000000 --- a/core/logic/msvc9/logic.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logic", "logic.vcproj", "{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/core/logic/msvc9/logic.vcproj b/core/logic/msvc9/logic.vcproj deleted file mode 100755 index ae9c2c4f..00000000 --- a/core/logic/msvc9/logic.vcproj +++ /dev/null @@ -1,379 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/logic/smn_admin.cpp b/core/logic/smn_admin.cpp index 0d7d6ea4..cac4f96b 100644 --- a/core/logic/smn_admin.cpp +++ b/core/logic/smn_admin.cpp @@ -585,6 +585,29 @@ REGISTER_NATIVES(adminNatives) {"SetAdmGroupImmunityLevel",SetAdmGroupImmunityLevel}, {"GetAdminImmunityLevel", GetAdminImmunityLevel}, {"SetAdminImmunityLevel", SetAdminImmunityLevel}, + {"AdminId.GetUsername", GetAdminUsername}, + {"AdminId.BindIdentity", BindAdminIdentity}, + {"AdminId.SetFlag", SetAdminFlag}, + {"AdminId.HasFlag", GetAdminFlag}, + {"AdminId.GetFlags", GetAdminFlags}, + {"AdminId.InheritGroup", AdminInheritGroup}, + {"AdminId.GetGroup", GetAdminGroup}, + {"AdminId.SetPassword", SetAdminPassword}, + {"AdminId.GetPassword", GetAdminPassword}, + {"AdminId.CanTarget", CanAdminTarget}, + {"AdminId.GroupCount.get", GetAdminGroupCount}, + {"AdminId.ImmunityLevel.get", GetAdminImmunityLevel}, + {"AdminId.ImmunityLevel.set", SetAdminImmunityLevel}, + {"GroupId.HasFlag", GetAdmGroupAddFlag}, + {"GroupId.SetFlag", SetAdmGroupAddFlag}, + {"GroupId.GetFlags", GetAdmGroupAddFlags}, + {"GroupId.GetGroupImmunity", GetAdmGroupImmuneFrom}, + {"GroupId.AddGroupImmunity", SetAdmGroupImmuneFrom}, + {"GroupId.GetCommandOverride", GetAdmGroupCmdOverride}, + {"GroupId.AddCommandOverride", AddAdmGroupCmdOverride}, + {"GroupId.GroupImmunitiesCount.get", GetAdmGroupImmuneCount}, + {"GroupId.ImmunityLevel.get", GetAdmGroupImmunityLevel}, + {"GroupId.ImmunityLevel.set", SetAdmGroupImmunityLevel}, /* -------------------------------------------------- */ {NULL, NULL}, }; diff --git a/core/logic/smn_adt_array.cpp b/core/logic/smn_adt_array.cpp index 299c85a9..eb039f41 100644 --- a/core/logic/smn_adt_array.cpp +++ b/core/logic/smn_adt_array.cpp @@ -8,7 +8,7 @@ * 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 @@ -35,7 +35,7 @@ HandleType_t htCellArray; -class CellArrayHelpers : +class CellArrayHelpers : public SMGlobalClass, public IHandleTypeDispatch { @@ -75,7 +75,7 @@ static cell_t CreateArray(IPluginContext *pContext, const cell_t *params) { array->resize(params[2]); } - + Handle_t hndl = handlesys->CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL); if (!hndl) { @@ -91,14 +91,14 @@ static cell_t ClearArray(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); } array->clear(); - + return 1; } @@ -108,7 +108,7 @@ static cell_t ResizeArray(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -128,7 +128,7 @@ static cell_t GetArraySize(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -143,7 +143,7 @@ static cell_t PushArrayCell(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -166,7 +166,7 @@ static cell_t PushArrayString(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -192,7 +192,7 @@ static cell_t PushArrayArray(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -224,7 +224,7 @@ static cell_t GetArrayCell(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -263,7 +263,7 @@ static cell_t GetArrayString(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -289,7 +289,7 @@ static cell_t GetArrayArray(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -322,7 +322,7 @@ static cell_t SetArrayCell(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -361,7 +361,7 @@ static cell_t SetArrayString(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -387,7 +387,7 @@ static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -420,7 +420,7 @@ static cell_t ShiftArrayUp(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -443,7 +443,7 @@ static cell_t RemoveFromArray(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -466,7 +466,7 @@ static cell_t SwapArrayItems(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -494,14 +494,14 @@ static cell_t CloneArray(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&oldArray)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&oldArray)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); } CellArray *array = oldArray->clone(); - + Handle_t hndl = handlesys->CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL); if (!hndl) { @@ -517,7 +517,7 @@ static cell_t FindStringInArray(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); @@ -544,15 +544,28 @@ static cell_t FindValueInArray(IPluginContext *pContext, const cell_t *params) HandleError err; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); - if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) + if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) != HandleError_None) { return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); } + // the blocknumber is not guaranteed to always be passed + size_t blocknumber = 0; + if (params[0] >= 3) + { + blocknumber = (size_t) params[3]; + } + + if (blocknumber >= array->blocksize()) + { + return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize()); + } + for (unsigned int i = 0; i < array->size(); i++) { - if (params[2] == *array->at(i)) + cell_t *blk = array->at(i); + if (params[2] == blk[blocknumber]) { return (cell_t) i; } diff --git a/core/logic/smn_adt_stack.cpp b/core/logic/smn_adt_stack.cpp index ef2ea737..9883ebef 100644 --- a/core/logic/smn_adt_stack.cpp +++ b/core/logic/smn_adt_stack.cpp @@ -304,7 +304,7 @@ static cell_t ArrayStack_Pop(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("stack is empty"); cell_t *blk = array->at(array->size() - 1); - cell_t idx = (size_t)params[2]; + size_t idx = (size_t)params[2]; cell_t rval; if (params[3] == 0) { diff --git a/core/logic/smn_adt_trie.cpp b/core/logic/smn_adt_trie.cpp index 94a57678..7b706489 100644 --- a/core/logic/smn_adt_trie.cpp +++ b/core/logic/smn_adt_trie.cpp @@ -63,11 +63,11 @@ public: : control_(0) { } - Entry(ke::Moveable other) + Entry(Entry &&other) { - control_ = other->control_; - data_ = other->data_; - other->control_ = 0; + control_ = other.control_; + data_ = other.data_; + other.control_ = 0; } ~Entry() diff --git a/core/logic/smn_console.cpp b/core/logic/smn_console.cpp index 963f4314..9b0ee6fa 100644 --- a/core/logic/smn_console.cpp +++ b/core/logic/smn_console.cpp @@ -150,11 +150,12 @@ static cell_t sm_ServerCommand(IPluginContext *pContext, const cell_t *params) g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); char buffer[1024]; - size_t len = g_pSM->FormatString(buffer, sizeof(buffer) - 2, pContext, params, 1); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) + size_t len; { - return 0; + DetectExceptions eh(pContext); + len = g_pSM->FormatString(buffer, sizeof(buffer) - 2, pContext, params, 1); + if (eh.HasException()) + return 0; } /* One byte for null terminator, one for newline */ @@ -171,11 +172,12 @@ static cell_t sm_InsertServerCommand(IPluginContext *pContext, const cell_t *par g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); char buffer[1024]; - size_t len = g_pSM->FormatString(buffer, sizeof(buffer) - 2, pContext, params, 1); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) + size_t len; { - return 0; + DetectExceptions eh(pContext); + len = g_pSM->FormatString(buffer, sizeof(buffer) - 2, pContext, params, 1); + if (eh.HasException()) + return 0; } /* One byte for null terminator, one for newline */ @@ -211,11 +213,12 @@ static cell_t sm_ClientCommand(IPluginContext *pContext, const cell_t *params) g_pSM->SetGlobalTarget(params[1]); char buffer[256]; - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) + size_t len; { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; } engine->ClientCommand(pPlayer->GetEdict(), buffer); @@ -240,11 +243,11 @@ static cell_t FakeClientCommand(IPluginContext *pContext, const cell_t *params) g_pSM->SetGlobalTarget(params[1]); char buffer[256]; - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; } engine->FakeClientCommand(pPlayer->GetEdict(), buffer); @@ -258,11 +261,13 @@ static cell_t ReplyToCommand(IPluginContext *pContext, const cell_t *params) /* Build the format string */ char buffer[1024]; - size_t len = g_pSM->FormatString(buffer, sizeof(buffer) - 2, pContext, params, 2); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) + size_t len; { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + len = g_pSM->FormatString(buffer, sizeof(buffer) - 2, pContext, params, 2); + if (eh.HasException()) + return 0; } /* If we're printing to the server, shortcut out */ diff --git a/core/logic/smn_core.cpp b/core/logic/smn_core.cpp index c595ebab..205e9942 100644 --- a/core/logic/smn_core.cpp +++ b/core/logic/smn_core.cpp @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourceMod * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. @@ -130,13 +130,14 @@ void LogAction(Handle_t hndl, int type, int client, int target, const char *mess g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); - - if (pContext->GetLastNativeError() == SP_ERROR_NONE) - { - pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", buffer); - } + { + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); + if (eh.HasException()) + return 0; + } + pContext->ReportError("%s", buffer); return 0; } @@ -388,16 +389,16 @@ static cell_t SetFailState(IPluginContext *pContext, const cell_t *params) { char buffer[2048]; - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) - { - pPlugin->SetErrorState(Plugin_Failed, "%s", str); - return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "Formatting error (%s)", str); - } - else - { + { + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); + if (eh.HasException()) { + pPlugin->SetErrorState(Plugin_Failed, "%s", str); + return 0; + } pPlugin->SetErrorState(Plugin_Failed, "%s", buffer); - return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", buffer); + pContext->ReportFatalError("%s", buffer); + return 0; } } @@ -457,7 +458,6 @@ static cell_t MarkNativeAsOptional(IPluginContext *pContext, const cell_t *param { char *name; uint32_t idx; - sp_native_t *native; pContext->LocalToString(params[1], &name); if (pContext->FindNativeByName(name, &idx) != SP_ERROR_NONE) @@ -466,10 +466,7 @@ static cell_t MarkNativeAsOptional(IPluginContext *pContext, const cell_t *param return 0; } - pContext->GetNativeByIndex(idx, &native); - - native->flags |= SP_NTVFLAG_OPTIONAL; - + pContext->GetRuntime()->UpdateNativeBinding(idx, nullptr, SP_NTVFLAG_OPTIONAL, nullptr); return 1; } @@ -511,12 +508,12 @@ static cell_t sm_LogAction(IPluginContext *pContext, const cell_t *params) { char buffer[2048]; g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 3); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) - { - return 0; - } + { + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 3); + if (eh.HasException()) + return 0; + } IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); @@ -540,14 +537,15 @@ static cell_t LogToFile(IPluginContext *pContext, const cell_t *params) } char buffer[2048]; - g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) - { - fclose(fp); - return 0; - } + { + DetectExceptions eh(pContext); + g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) { + fclose(fp); + return 0; + } + } IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); @@ -573,14 +571,15 @@ static cell_t LogToFileEx(IPluginContext *pContext, const cell_t *params) } char buffer[2048]; - g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) - { - fclose(fp); - return 0; - } + { + DetectExceptions eh(pContext); + g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) { + fclose(fp); + return 0; + } + } g_Logger.LogToOpenFile(fp, "%s", buffer); @@ -652,21 +651,27 @@ static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params) if (sharesys->TestFeature(pContext->GetRuntime(), type, name) != FeatureStatus_Available) { - char buffer[255]; - char *msg = buffer; - char default_message[255]; + char buffer[255]; + char *msg = buffer; + char default_message[255]; SMPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); - - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 3); - if (pContext->GetLastNativeError() != SP_ERROR_NONE || buffer[0] == '\0') - { - g_pSM->Format(default_message, sizeof(default_message), "Feature \"%s\" not available", name); - msg = default_message; - } - pPlugin->SetErrorState(Plugin_Error, "%s", msg); - return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", msg); - } - + + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 3); + if (eh.HasException()) + buffer[0] = '\0'; + + if (buffer[0] == '\0') { + g_pSM->Format(default_message, sizeof(default_message), "Feature \"%s\" not available", name); + msg = default_message; + } + pPlugin->SetErrorState(Plugin_Error, "%s", msg); + + if (!eh.HasException()) + pContext->ReportFatalError("%s", msg); + return 0; + } + return 1; } diff --git a/core/logic/smn_database.cpp b/core/logic/smn_database.cpp index 4d134294..f0beda05 100644 --- a/core/logic/smn_database.cpp +++ b/core/logic/smn_database.cpp @@ -334,9 +334,9 @@ public: { m_pDatabase->Close(); } - m_pFunction->PushCell(BAD_HANDLE); if (m_ACM == ACM_Old) m_pFunction->PushCell(BAD_HANDLE); + m_pFunction->PushCell(BAD_HANDLE); m_pFunction->PushString("Driver is unloading"); m_pFunction->PushCell(m_Data); m_pFunction->Execute(NULL); @@ -355,9 +355,9 @@ public: } } - m_pFunction->PushCell(m_pDriver->GetHandle()); if (m_ACM == ACM_Old) - m_pFunction->PushCell(hndl); + m_pFunction->PushCell(m_pDriver->GetHandle()); + m_pFunction->PushCell(hndl); m_pFunction->PushString(hndl == BAD_HANDLE ? error : ""); m_pFunction->PushCell(m_Data); m_pFunction->Execute(NULL); diff --git a/core/logic/smn_datapacks.cpp b/core/logic/smn_datapacks.cpp index 2612abbc..9a369dbe 100644 --- a/core/logic/smn_datapacks.cpp +++ b/core/logic/smn_datapacks.cpp @@ -125,7 +125,6 @@ static cell_t smn_WritePackString(IPluginContext *pContext, const cell_t *params HandleError herr; HandleSecurity sec; IDataPack *pDataPack; - int err; sec.pOwner = pContext->GetIdentity(); sec.pIdentity = g_pCoreIdent; @@ -137,12 +136,7 @@ static cell_t smn_WritePackString(IPluginContext *pContext, const cell_t *params } char *str; - if ((err=pContext->LocalToString(params[2], &str)) != SP_ERROR_NONE) - { - pContext->ThrowNativeErrorEx(err, NULL); - return 0; - } - + pContext->LocalToString(params[2], &str); pDataPack->PackString(str); return 1; diff --git a/core/logic/smn_fakenatives.cpp b/core/logic/smn_fakenatives.cpp index f5f9d66a..3d785804 100644 --- a/core/logic/smn_fakenatives.cpp +++ b/core/logic/smn_fakenatives.cpp @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet: * ============================================================================= * SourceMod * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. @@ -81,18 +81,12 @@ cell_t FakeNativeRouter(IPluginContext *pContext, const cell_t *params, void *pD s_curparams[i] = params[i]; } - /* Push info and execute. */ + // Push info and execute. If Invoke() fails, the error will propagate up. + // We still carry on below to clear our global state. cell_t result = 0; native->call->PushCell(pCaller->GetMyHandle()); native->call->PushCell(params[0]); - int error; - if ((error=native->call->Execute(&result)) != SP_ERROR_NONE) - { - if (pContext->GetLastNativeError() == SP_ERROR_NONE) - { - pContext->ThrowNativeErrorEx(error, "Error encountered while processing a dynamic native"); - } - } + native->call->Invoke(&result); /* Restore everything from the stack if necessary */ s_curnative = pSaveNative; @@ -141,15 +135,15 @@ static cell_t ThrowNativeError(IPluginContext *pContext, const cell_t *params) g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); char buffer[512]; - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - s_curcaller->ThrowNativeError("Error encountered while processing a dynamic native"); - } else { - s_curcaller->ThrowNativeErrorEx(params[1], "%s", buffer); + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; } + pContext->ReportError("%s", buffer); return 0; } @@ -402,36 +396,32 @@ static cell_t FormatNativeString(IPluginContext *pContext, const cell_t *params) char *format_buffer; if (out_param) - { - if ((err=s_curcaller->LocalToString(s_curparams[out_param], &output_buffer)) != SP_ERROR_NONE) - { - return err; - } - } else { + s_curcaller->LocalToString(s_curparams[out_param], &output_buffer); + else pContext->LocalToString(params[6], &output_buffer); - } if (fmt_param) - { - if ((err=s_curcaller->LocalToString(s_curparams[fmt_param], &format_buffer)) != SP_ERROR_NONE) - { - return err; - } - } else { + s_curcaller->LocalToString(s_curparams[fmt_param], &format_buffer); + else pContext->LocalToString(params[7], &format_buffer); - } /* Get maximum length */ size_t maxlen = (size_t)params[4]; /* Do the format */ - size_t written = smcore.atcprintf(output_buffer, maxlen, format_buffer, s_curcaller, s_curparams, &var_param); + size_t written; + { + DetectExceptions eh(pContext); + written = smcore.atcprintf(output_buffer, maxlen, format_buffer, s_curcaller, s_curparams, &var_param); + if (eh.HasException()) + return 0; + } cell_t *addr; pContext->LocalToPhysAddr(params[5], &addr); *addr = (cell_t)written; - return s_curcaller->GetLastNativeError(); + return SP_ERROR_NONE; } //tee hee diff --git a/core/logic/smn_filesystem.cpp b/core/logic/smn_filesystem.cpp index 692edc0e..6581f2e9 100644 --- a/core/logic/smn_filesystem.cpp +++ b/core/logic/smn_filesystem.cpp @@ -309,7 +309,7 @@ static cell_t sm_OpenDirectory(IPluginContext *pContext, const cell_t *params) if (!path[0]) { - return pContext->ThrowNativeError("Invalid file path"); + return pContext->ThrowNativeError("Invalid path. An empty path string is not valid, use \".\" to refer to the current working directory."); } Handle_t handle = 0; @@ -616,7 +616,12 @@ static cell_t sm_DirExists(IPluginContext *pContext, const cell_t *params) { char *name; pContext->LocalToString(params[1], &name); - + + if (!name[0]) + { + return pContext->ThrowNativeError("Invalid path. An empty path string is not valid, use \".\" to refer to the current working directory."); + } + if (params[0] >= 2 && params[2] == 1) { char *pathID; @@ -765,9 +770,12 @@ static cell_t sm_WriteFileLine(IPluginContext *pContext, const cell_t *params) int arg = 3; char buffer[2048]; - smcore.atcprintf(buffer, sizeof(buffer), fmt, pContext, params, &arg); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) - return 0; + { + DetectExceptions eh(pContext); + smcore.atcprintf(buffer, sizeof(buffer), fmt, pContext, params, &arg); + if (eh.HasException()) + return 0; + } if (SystemFile *sysfile = file->AsSystemFile()) { fprintf(sysfile->fp(), "%s\n", buffer); @@ -797,9 +805,12 @@ static cell_t sm_BuildPath(IPluginContext *pContext, const cell_t *params) pContext->LocalToString(params[2], &buffer); pContext->LocalToString(params[4], &fmt); - smcore.atcprintf(path, sizeof(path), fmt, pContext, params, &arg); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) - return 0; + { + DetectExceptions eh(pContext); + smcore.atcprintf(path, sizeof(path), fmt, pContext, params, &arg); + if (eh.HasException()) + return 0; + } return g_pSM->BuildPath(Path_SM_Rel, buffer, params[3], "%s", path); } @@ -808,12 +819,13 @@ static cell_t sm_LogToGame(IPluginContext *pContext, const cell_t *params) { g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); + size_t len; char buffer[1024]; - size_t len = g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + len = g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); + if (eh.HasException()) + return 0; } if (len >= sizeof(buffer)-2) @@ -835,11 +847,11 @@ static cell_t sm_LogMessage(IPluginContext *pContext, const cell_t *params) g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); char buffer[1024]; - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); + if (eh.HasException()) + return 0; } IPlugin *pPlugin = pluginsys->FindPluginByContext(pContext->GetContext()); @@ -853,11 +865,11 @@ static cell_t sm_LogError(IPluginContext *pContext, const cell_t *params) g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); char buffer[1024]; - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); + if (eh.HasException()) + return 0; } IPlugin *pPlugin = pluginsys->FindPluginByContext(pContext->GetContext()); @@ -900,9 +912,12 @@ static cell_t sm_LogToOpenFile(IPluginContext *pContext, const cell_t *params) char buffer[2048]; g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) - return 0; + { + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; + } IPlugin *pPlugin = pluginsys->FindPluginByContext(pContext->GetContext()); g_Logger.LogToOpenFile(sysfile->fp(), "[%s] %s", pPlugin->GetFilename(), buffer); @@ -922,9 +937,12 @@ static cell_t sm_LogToOpenFileEx(IPluginContext *pContext, const cell_t *params) char buffer[2048]; g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) - return 0; + { + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; + } g_Logger.LogToOpenFile(sysfile->fp(), "%s", buffer); return 1; @@ -1176,6 +1194,7 @@ REGISTER_NATIVES(filesystem) {"File.ReadInt8", File_ReadTyped}, {"File.ReadUint8", File_ReadTyped}, {"File.ReadInt16", File_ReadTyped}, + {"File.ReadUint16", File_ReadTyped}, {"File.ReadInt32", File_ReadTyped}, {"File.WriteInt8", File_WriteTyped}, {"File.WriteInt16", File_WriteTyped}, diff --git a/core/logic/smn_functions.cpp b/core/logic/smn_functions.cpp index 82308bf8..4b0ea105 100644 --- a/core/logic/smn_functions.cpp +++ b/core/logic/smn_functions.cpp @@ -564,6 +564,7 @@ static cell_t sm_CallFinish(IPluginContext *pContext, const cell_t *params) pContext->LocalToPhysAddr(params[1], &result); + // Note: Execute() swallows exceptions, so this is okay. if (s_pFunction) { IPluginFunction *pFunction = s_pFunction; diff --git a/core/logic/smn_maplists.cpp b/core/logic/smn_maplists.cpp index 9faba5d8..c1a1ac52 100644 --- a/core/logic/smn_maplists.cpp +++ b/core/logic/smn_maplists.cpp @@ -87,28 +87,16 @@ public: } void GetMapCycleFilePath(char *pBuffer, int maxlen) { - const char *pEngineName = smcore.GetSourceEngineName(); const char *pMapCycleFileName = m_pMapCycleFile ? smcore.GetCvarString(m_pMapCycleFile) : "mapcycle.txt"; - if (strcmp(pEngineName, "tf2") == 0 || strcmp(pEngineName, "css") == 0 - || strcmp(pEngineName, "dods") == 0 || strcmp(pEngineName, "hl2dm") == 0) - { - // These four games and Source SDK 2013 do a lookup in this order; so shall we. - g_pSM->Format(pBuffer, maxlen, "cfg/%s", pMapCycleFileName); - - if (!smcore.filesystem->FileExists(pBuffer, "GAME")) - { - g_pSM->Format(pBuffer, maxlen, "%s", pMapCycleFileName); - - if (!smcore.filesystem->FileExists(pBuffer, "GAME")) - { - g_pSM->Format(pBuffer, maxlen, "cfg/mapcycle_default.txt"); - } - } - } - else + g_pSM->Format(pBuffer, maxlen, "cfg/%s", pMapCycleFileName); + if (!smcore.filesystem->FileExists(pBuffer, "GAME")) { g_pSM->Format(pBuffer, maxlen, "%s", pMapCycleFileName); + if (!smcore.filesystem->FileExists(pBuffer, "GAME")) + { + g_pSM->Format(pBuffer, maxlen, "cfg/mapcycle_default.txt"); + } } } void AddOrUpdateDefault(const char *name, const char *file) diff --git a/core/logic/smn_players.cpp b/core/logic/smn_players.cpp index 96bd262d..8dbb8c91 100644 --- a/core/logic/smn_players.cpp +++ b/core/logic/smn_players.cpp @@ -1087,11 +1087,12 @@ static cell_t _ShowActivity(IPluginContext *pContext, if (replyto == SM_REPLY_CONSOLE) { g_pSM->SetGlobalTarget(client); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + if (eh.HasException()) + return 0; } g_pSM->Format(message, sizeof(message), "%s%s\n", tag, buffer); @@ -1102,11 +1103,12 @@ static cell_t _ShowActivity(IPluginContext *pContext, else { g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + if (eh.HasException()) + return 0; } g_pSM->Format(message, sizeof(message), "%s%s\n", tag, buffer); @@ -1141,11 +1143,12 @@ static cell_t _ShowActivity(IPluginContext *pContext, { newsign = name; } - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + if (eh.HasException()) + return 0; } g_pSM->Format(message, sizeof(message), "%s%s: %s", tag, newsign, buffer); @@ -1165,11 +1168,12 @@ static cell_t _ShowActivity(IPluginContext *pContext, { newsign = name; } - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + if (eh.HasException()) + return 0; } g_pSM->Format(message, sizeof(message), "%s%s: %s", tag, newsign, buffer); @@ -1210,11 +1214,11 @@ static cell_t _ShowActivity2(IPluginContext *pContext, } g_pSM->SetGlobalTarget(client); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + if (eh.HasException()) + return 0; } /* We don't display directly to the console because the chat text @@ -1227,11 +1231,11 @@ static cell_t _ShowActivity2(IPluginContext *pContext, else { g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + if (eh.HasException()) + return 0; } g_pSM->Format(message, sizeof(message), "%s%s\n", tag, buffer); @@ -1266,11 +1270,12 @@ static cell_t _ShowActivity2(IPluginContext *pContext, { newsign = name; } - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + if (eh.HasException()) + return 0; } g_pSM->Format(message, sizeof(message), "%s%s: %s", tag, newsign, buffer); @@ -1290,11 +1295,12 @@ static cell_t _ShowActivity2(IPluginContext *pContext, { newsign = name; } - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, fmt_param); + if (eh.HasException()) + return 0; } g_pSM->Format(message, sizeof(message), "%s%s: %s", tag, newsign, buffer); @@ -1350,11 +1356,11 @@ static cell_t KickClient(IPluginContext *pContext, const cell_t *params) g_pSM->SetGlobalTarget(client); char buffer[256]; - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; } if (pPlayer->IsFakeClient()) @@ -1387,11 +1393,11 @@ static cell_t KickClientEx(IPluginContext *pContext, const cell_t *params) g_pSM->SetGlobalTarget(client); char buffer[256]; - g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; } pPlayer->Kick(buffer); diff --git a/core/logic/smn_sorting.cpp b/core/logic/smn_sorting.cpp index 65d0a5db..7d175ee1 100644 --- a/core/logic/smn_sorting.cpp +++ b/core/logic/smn_sorting.cpp @@ -232,6 +232,7 @@ static cell_t sm_SortStrings(IPluginContext *pContext, const cell_t *params) if ((err=pContext->HeapAlloc(array_size, &amx_addr, &phys_addr)) != SP_ERROR_NONE) { pContext->ThrowNativeErrorEx(err, "Ran out of memory to sort"); + return 0; } g_CurStringArray = array; @@ -282,12 +283,16 @@ struct sort_info cell_t array_addr; cell_t *array_base; cell_t *array_remap; + ExceptionHandler *eh; }; sort_info g_SortInfo; int sort1d_amx_custom(const void *elem1, const void *elem2) { + if (g_SortInfo.eh->HasException()) + return 0; + cell_t c1 = *(cell_t *)elem1; cell_t c2 = *(cell_t *)elem2; @@ -297,7 +302,7 @@ int sort1d_amx_custom(const void *elem1, const void *elem2) pf->PushCell(c2); pf->PushCell(g_SortInfo.array_addr); pf->PushCell(g_SortInfo.hndl); - pf->Execute(&result); + pf->Invoke(&result); return result; } @@ -317,22 +322,25 @@ static cell_t sm_SortCustom1D(IPluginContext *pContext, const cell_t *params) sort_info oldinfo = g_SortInfo; - + DetectExceptions eh(pContext); g_SortInfo.hndl = params[4]; g_SortInfo.array_addr = params[1]; g_SortInfo.array_remap = NULL; g_SortInfo.array_base = NULL; g_SortInfo.pFunc = pFunction; + g_SortInfo.eh = &eh; qsort(array, array_size, sizeof(cell_t), sort1d_amx_custom); g_SortInfo = oldinfo; - return 1; } int sort2d_amx_custom(const void *elem1, const void *elem2) { + if (g_SortInfo.eh->HasException()) + return 0; + cell_t c1 = *(cell_t *)elem1; cell_t c2 = *(cell_t *)elem2; @@ -349,7 +357,7 @@ int sort2d_amx_custom(const void *elem1, const void *elem2) g_SortInfo.pFunc->PushCell(c2_addr); g_SortInfo.pFunc->PushCell(g_SortInfo.array_addr); g_SortInfo.pFunc->PushCell(g_SortInfo.hndl); - g_SortInfo.pFunc->Execute(&result); + g_SortInfo.pFunc->Invoke(&result); return result; } @@ -378,9 +386,11 @@ static cell_t sm_SortCustom2D(IPluginContext *pContext, const cell_t *params) sort_info oldinfo = g_SortInfo; + DetectExceptions eh(pContext); g_SortInfo.pFunc = pFunction; g_SortInfo.hndl = params[4]; g_SortInfo.array_addr = params[1]; + g_SortInfo.eh = &eh; /** Same process as in strings, back up the old indices for later fixup */ g_SortInfo.array_base = array; @@ -511,19 +521,23 @@ struct sort_infoADT cell_t array_bsize; Handle_t array_hndl; Handle_t hndl; + ExceptionHandler *eh; }; sort_infoADT g_SortInfoADT; int sort_adtarray_custom(const void *elem1, const void *elem2) { + if (g_SortInfoADT.eh->HasException()) + return 0; + cell_t result = 0; IPluginFunction *pf = g_SortInfoADT.pFunc; pf->PushCell(((cell_t) ((cell_t *) elem1 - g_SortInfoADT.array_base)) / g_SortInfoADT.array_bsize); pf->PushCell(((cell_t) ((cell_t *) elem2 - g_SortInfoADT.array_base)) / g_SortInfoADT.array_bsize); pf->PushCell(g_SortInfoADT.array_hndl); pf->PushCell(g_SortInfoADT.hndl); - pf->Execute(&result); + pf->Invoke(&result); return result; } @@ -552,11 +566,13 @@ static cell_t sm_SortADTArrayCustom(IPluginContext *pContext, const cell_t *para sort_infoADT oldinfo = g_SortInfoADT; + DetectExceptions eh(pContext); g_SortInfoADT.pFunc = pFunction; g_SortInfoADT.array_base = array; g_SortInfoADT.array_bsize = (cell_t) blocksize; g_SortInfoADT.array_hndl = params[1]; g_SortInfoADT.hndl = params[3]; + g_SortInfoADT.eh = &eh; qsort(array, arraysize, blocksize * sizeof(cell_t), sort_adtarray_custom); diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp index 8fc82e53..bec62764 100644 --- a/core/logic_bridge.cpp +++ b/core/logic_bridge.cpp @@ -373,6 +373,8 @@ static const char *get_source_engine_name() return "dods"; #elif SOURCE_ENGINE == SE_SDK2013 return "sdk2013"; +#elif SOURCE_ENGINE == SE_BMS + return "bms"; #elif SOURCE_ENGINE == SE_TF2 return "tf2"; #elif SOURCE_ENGINE == SE_LEFT4DEAD @@ -404,6 +406,7 @@ static bool symbols_are_hidden() || (SOURCE_ENGINE == SE_HL2DM) \ || (SOURCE_ENGINE == SE_DODS) \ || (SOURCE_ENGINE == SE_SDK2013) \ + || (SOURCE_ENGINE == SE_BMS) \ || (SOURCE_ENGINE == SE_TF2) \ || (SOURCE_ENGINE == SE_LEFT4DEAD) \ || (SOURCE_ENGINE == SE_NUCLEARDAWN) \ @@ -540,6 +543,8 @@ void do_global_plugin_loads() #define GAMEFIX "2.dods" #elif SOURCE_ENGINE == SE_SDK2013 #define GAMEFIX "2.sdk2013" +#elif SOURCE_ENGINE == SE_BMS +#define GAMEFIX "2.bms" #elif SOURCE_ENGINE == SE_TF2 #define GAMEFIX "2.tf2" #elif SOURCE_ENGINE == SE_DARKMESSIAH diff --git a/core/msvc10/sourcemod_mm.sln b/core/msvc10/sourcemod_mm.sln deleted file mode 100644 index c720ff55..00000000 --- a/core/msvc10/sourcemod_mm.sln +++ /dev/null @@ -1,95 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sourcemod_mm", "sourcemod_mm.vcxproj", "{E39527CD-7CAB-4420-97CC-DA1B93B260BC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - CrazyDebug - Alien Swarm|Win32 = CrazyDebug - Alien Swarm|Win32 - CrazyDebug - CS GO|Win32 = CrazyDebug - CS GO|Win32 - CrazyDebug - Dark Messiah|Win32 = CrazyDebug - Dark Messiah|Win32 - CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|Win32 - CrazyDebug - Left 4 Dead 2|Win32 = CrazyDebug - Left 4 Dead 2|Win32 - CrazyDebug - Left 4 Dead|Win32 = CrazyDebug - Left 4 Dead|Win32 - CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32 - CrazyDebug - Orange Box Valve|Win32 = CrazyDebug - Orange Box Valve|Win32 - CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32 - Debug - Alien Swarm|Win32 = Debug - Alien Swarm|Win32 - Debug - CS GO|Win32 = Debug - CS GO|Win32 - Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 - Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Release - Alien Swarm|Win32 = Release - Alien Swarm|Win32 - Release - CS GO|Win32 = Release - CS GO|Win32 - Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 - Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = CrazyDebug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Alien Swarm|Win32.Build.0 = CrazyDebug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - CS GO|Win32.ActiveCfg = CrazyDebug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - CS GO|Win32.Build.0 = CrazyDebug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = CrazyDebug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.Build.0 = CrazyDebug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.ActiveCfg = CrazyDebug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.Build.0 = CrazyDebug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = CrazyDebug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = CrazyDebug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = CrazyDebug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.Build.0 = CrazyDebug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.ActiveCfg = CrazyDebug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.Build.0 = CrazyDebug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = CrazyDebug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.Build.0 = CrazyDebug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.ActiveCfg = CrazyDebug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.Build.0 = CrazyDebug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Alien Swarm|Win32.Build.0 = Debug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Alien Swarm|Win32.ActiveCfg = Release - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Alien Swarm|Win32.Build.0 = Release - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/core/msvc10/sourcemod_mm.vcxproj b/core/msvc10/sourcemod_mm.vcxproj deleted file mode 100644 index 82b0283b..00000000 --- a/core/msvc10/sourcemod_mm.vcxproj +++ /dev/null @@ -1,2443 +0,0 @@ - - - - - CrazyDebug - Alien Swarm - Win32 - - - CrazyDebug - Bloody Good Time - Win32 - - - CrazyDebug - CS GO - Win32 - - - CrazyDebug - CSS - Win32 - - - CrazyDebug - Dark Messiah - Win32 - - - CrazyDebug - Episode 1 - Win32 - - - CrazyDebug - EYE - Win32 - - - CrazyDebug - Left 4 Dead 2 - Win32 - - - CrazyDebug - Left 4 Dead - Win32 - - - CrazyDebug - Old Metamod - Win32 - - - CrazyDebug - Orange Box Valve - Win32 - - - CrazyDebug - Orange Box - Win32 - - - Debug - Alien Swarm - Win32 - - - Debug - Bloody Good Time - Win32 - - - Debug - CS GO - Win32 - - - Debug - CSS - Win32 - - - Debug - Dark Messiah - Win32 - - - Debug - Episode 1 - Win32 - - - Debug - EYE - Win32 - - - Debug - Left 4 Dead 2 - Win32 - - - Debug - Left 4 Dead - Win32 - - - Debug - Old Metamod - Win32 - - - Debug - Orange Box Valve - Win32 - - - Debug - Orange Box - Win32 - - - Release - Alien Swarm - Win32 - - - Release - Bloody Good Time - Win32 - - - Release - CS GO - Win32 - - - Release - CSS - Win32 - - - Release - Dark Messiah - Win32 - - - Release - Episode 1 - Win32 - - - Release - EYE - Win32 - - - Release - Left 4 Dead 2 - Win32 - - - Release - Left 4 Dead - Win32 - - - Release - Old Metamod - Win32 - - - Release - Orange Box Valve - Win32 - - - Release - Orange Box - Win32 - - - - {E39527CD-7CAB-4420-97CC-DA1B93B260BC} - sourcemod_mm - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - true - true - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - true - true - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - false - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - sourcemod.2.swarm - sourcemod.2.swarm - sourcemod.2.swarm - sourcemod.2.bgt - sourcemod.2.bgt - sourcemod.2.bgt - sourcemod.2.csgo - sourcemod.2.csgo - sourcemod.2.csgo - sourcemod.2.ep1 - sourcemod.2.ep1 - sourcemod.2.ep1 - sourcemod.2.eye - sourcemod.2.eye - sourcemod.2.eye - sourcemod.2.l4d - sourcemod.2.l4d - sourcemod.2.l4d - sourcemod.2.l4d2 - sourcemod.2.l4d2 - sourcemod.2.l4d2 - sourcemod.1.ep1 - sourcemod.1.ep1 - sourcemod.1.ep1 - sourcemod.2.ep2 - sourcemod.2.ep2 - sourcemod.2.ep2 - sourcemod.2.ep2v - sourcemod.2.css - sourcemod.2.ep2v - sourcemod.2.css - sourcemod.2.ep2v - sourcemod.2.css - - - sourcemod.2.darkm - - - sourcemod.2.darkm - - - sourcemod.2.darkm - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\mathlib;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(HL2SDK-DARKM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;$(HL2SDK-DARKM)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\mathlib;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(HL2SDK-DARKM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;$(HL2SDK-DARKM)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\mathlib;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(HL2SDK-DARKM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;$(HL2SDK-DARKM)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\mathlib;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(HL2SDKOB)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;$(HL2SDKOB)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\mathlib;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(HL2SDKOB)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;$(HL2SDKOB)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\mathlib;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(HL2SDKOB)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;$(HL2SDKOB)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\mathlib;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(HL2SDKL4D)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;$(HL2SDKL4D)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\mathlib;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(HL2SDKL4D)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;$(HL2SDKL4D)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\mathlib;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(HL2SDKL4D)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;$(HL2SDKL4D)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\mathlib;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(HL2SDKOBVALVE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;$(HL2SDKOBVALVE)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\mathlib;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(HL2SDKCSS)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;$(HL2SDKCSS)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\mathlib;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(HL2SDKOBVALVE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;$(HL2SDKOBVALVE)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\mathlib;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(HL2SDKCSS)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;$(HL2SDKCSS)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\mathlib;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(HL2SDKOBVALVE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;$(HL2SDKOBVALVE)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\mathlib;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(HL2SDKCSS)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;$(HL2SDKCSS)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\mathlib;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(HL2SDKL4D2)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKL4D2)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\mathlib;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(HL2SDKL4D2)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKL4D2)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\mathlib;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(HL2SDKL4D2)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKL4D2)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\mathlib;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(HL2SDK-BGT)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=4;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;$(HL2SDK-BGT)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\mathlib;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(HL2SDK-BGT)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=4;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;$(HL2SDK-BGT)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\mathlib;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(HL2SDK-BGT)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=4;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;$(HL2SDK-BGT)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\mathlib;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(HL2SDK-EYE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=5;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;$(HL2SDK-EYE)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\mathlib;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(HL2SDK-EYE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=5;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;$(HL2SDK-EYE)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\mathlib;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(HL2SDK-EYE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=5;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;$(HL2SDK-EYE)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\mathlib;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(HL2SDK-SWARM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=10;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;$(HL2SDK-SWARM)\lib\public\mathlib.lib;$(HL2SDK-SWARM)\lib\public\interfaces.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\mathlib;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(HL2SDK-SWARM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=10;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;$(HL2SDK-SWARM)\lib\public\mathlib.lib;$(HL2SDK-SWARM)\lib\public\interfaces.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\mathlib;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(HL2SDK-SWARM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=10;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;$(HL2SDK-SWARM)\lib\public\mathlib.lib;$(HL2SDK-SWARM)\lib\public\interfaces.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSGO)\common\protobuf-2.3.0\src;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\engine\protobuf;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\game\shared\csgo\protobuf;$(HL2SDKCSGO)\public\mathlib;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(HL2SDKCSGO)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - _ITERATOR_DEBUG_LEVEL=0;WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\mathlib.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSGO)\common\protobuf-2.3.0\src;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\engine\protobuf;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\game\shared\csgo\protobuf;$(HL2SDKCSGO)\public\mathlib;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(HL2SDKCSGO)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - _ITERATOR_DEBUG_LEVEL=0;WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\mathlib.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSGO)\common\protobuf-2.3.0\src;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\engine\protobuf;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\game\shared\csgo\protobuf;$(HL2SDKCSGO)\public\mathlib;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(HL2SDKCSGO)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\mathlib.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - - - - - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - - - - - - - - - - - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - - - - - - true - true - true - - - - - - - - - - - - - - - - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - \ No newline at end of file diff --git a/core/msvc10/sourcemod_mm.vcxproj.filters b/core/msvc10/sourcemod_mm.vcxproj.filters deleted file mode 100644 index 0bb5412e..00000000 --- a/core/msvc10/sourcemod_mm.vcxproj.filters +++ /dev/null @@ -1,439 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {10C69360-9E8E-4a43-BCEF-E9373B3641BC} - - - {C3C3DC6E-E392-4916-B893-7ACB92192DE0} - - - {80B56842-7A9F-4d5d-8149-767C285D0EB4} - - - {052D6D9B-7B50-4c3c-9B82-32CA908DEF24} - - - {2A750240-7C10-455f-A900-B9A9D362356C} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {28cf0347-3553-4d24-b9ad-476ba5197680} - - - {0e62c72e-57b1-40d2-9a94-059f535ce719} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - Natives - - - HL2SDK\Protobuf\CSGO - - - HL2SDK\Protobuf\CSGO - - - HL2SDK\Protobuf - - - Natives - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - Interfaces - - - SourcePawn - - - SourcePawn - - - SourcePawn - - - SourcePawn - - - SourcePawn - - - HL2SDK - - - Header Files - - - Header Files - - - HL2SDK - - - HL2SDK - - - HL2SDK - - - HL2SDK\Protobuf\CSGO - - - HL2SDK\Protobuf\CSGO - - - HL2SDK\Protobuf - - - - - Resources - - - - - HL2SDK\Protobuf - - - HL2SDK\Protobuf - - - \ No newline at end of file diff --git a/core/msvc11/sourcemod_mm.sln b/core/msvc11/sourcemod_mm.sln deleted file mode 100644 index c720ff55..00000000 --- a/core/msvc11/sourcemod_mm.sln +++ /dev/null @@ -1,95 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sourcemod_mm", "sourcemod_mm.vcxproj", "{E39527CD-7CAB-4420-97CC-DA1B93B260BC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - CrazyDebug - Alien Swarm|Win32 = CrazyDebug - Alien Swarm|Win32 - CrazyDebug - CS GO|Win32 = CrazyDebug - CS GO|Win32 - CrazyDebug - Dark Messiah|Win32 = CrazyDebug - Dark Messiah|Win32 - CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|Win32 - CrazyDebug - Left 4 Dead 2|Win32 = CrazyDebug - Left 4 Dead 2|Win32 - CrazyDebug - Left 4 Dead|Win32 = CrazyDebug - Left 4 Dead|Win32 - CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32 - CrazyDebug - Orange Box Valve|Win32 = CrazyDebug - Orange Box Valve|Win32 - CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32 - Debug - Alien Swarm|Win32 = Debug - Alien Swarm|Win32 - Debug - CS GO|Win32 = Debug - CS GO|Win32 - Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 - Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Release - Alien Swarm|Win32 = Release - Alien Swarm|Win32 - Release - CS GO|Win32 = Release - CS GO|Win32 - Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 - Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = CrazyDebug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Alien Swarm|Win32.Build.0 = CrazyDebug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - CS GO|Win32.ActiveCfg = CrazyDebug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - CS GO|Win32.Build.0 = CrazyDebug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = CrazyDebug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.Build.0 = CrazyDebug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.ActiveCfg = CrazyDebug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.Build.0 = CrazyDebug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = CrazyDebug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = CrazyDebug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = CrazyDebug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.Build.0 = CrazyDebug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.ActiveCfg = CrazyDebug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.Build.0 = CrazyDebug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = CrazyDebug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.Build.0 = CrazyDebug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.ActiveCfg = CrazyDebug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.Build.0 = CrazyDebug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Alien Swarm|Win32.Build.0 = Debug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Alien Swarm|Win32.ActiveCfg = Release - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Alien Swarm|Win32.Build.0 = Release - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/core/msvc11/sourcemod_mm.vcxproj b/core/msvc11/sourcemod_mm.vcxproj deleted file mode 100644 index 22185bd9..00000000 --- a/core/msvc11/sourcemod_mm.vcxproj +++ /dev/null @@ -1,2479 +0,0 @@ - - - - - CrazyDebug - Alien Swarm - Win32 - - - CrazyDebug - Bloody Good Time - Win32 - - - CrazyDebug - CS GO - Win32 - - - CrazyDebug - CSS - Win32 - - - CrazyDebug - Dark Messiah - Win32 - - - CrazyDebug - Episode 1 - Win32 - - - CrazyDebug - EYE - Win32 - - - CrazyDebug - Left 4 Dead 2 - Win32 - - - CrazyDebug - Left 4 Dead - Win32 - - - CrazyDebug - Old Metamod - Win32 - - - CrazyDebug - Orange Box Valve - Win32 - - - CrazyDebug - Orange Box - Win32 - - - Debug - Alien Swarm - Win32 - - - Debug - Bloody Good Time - Win32 - - - Debug - CS GO - Win32 - - - Debug - CSS - Win32 - - - Debug - Dark Messiah - Win32 - - - Debug - Episode 1 - Win32 - - - Debug - EYE - Win32 - - - Debug - Left 4 Dead 2 - Win32 - - - Debug - Left 4 Dead - Win32 - - - Debug - Old Metamod - Win32 - - - Debug - Orange Box Valve - Win32 - - - Debug - Orange Box - Win32 - - - Release - Alien Swarm - Win32 - - - Release - Bloody Good Time - Win32 - - - Release - CS GO - Win32 - - - Release - CSS - Win32 - - - Release - Dark Messiah - Win32 - - - Release - Episode 1 - Win32 - - - Release - EYE - Win32 - - - Release - Left 4 Dead 2 - Win32 - - - Release - Left 4 Dead - Win32 - - - Release - Old Metamod - Win32 - - - Release - Orange Box Valve - Win32 - - - Release - Orange Box - Win32 - - - - {E39527CD-7CAB-4420-97CC-DA1B93B260BC} - sourcemod_mm - Win32Proj - - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - DynamicLibrary - MultiByte - v110 - - - DynamicLibrary - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - true - true - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - true - true - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - false - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - sourcemod.2.swarm - sourcemod.2.swarm - sourcemod.2.swarm - sourcemod.2.bgt - sourcemod.2.bgt - sourcemod.2.bgt - sourcemod.2.csgo - sourcemod.2.csgo - sourcemod.2.csgo - sourcemod.2.ep1 - sourcemod.2.ep1 - sourcemod.2.ep1 - sourcemod.2.eye - sourcemod.2.eye - sourcemod.2.eye - sourcemod.2.l4d - sourcemod.2.l4d - sourcemod.2.l4d - sourcemod.2.l4d2 - sourcemod.2.l4d2 - sourcemod.2.l4d2 - sourcemod.1.ep1 - sourcemod.1.ep1 - sourcemod.1.ep1 - sourcemod.2.ep2 - sourcemod.2.ep2 - sourcemod.2.ep2 - sourcemod.2.ep2v - sourcemod.2.css - sourcemod.2.ep2v - sourcemod.2.css - sourcemod.2.ep2v - sourcemod.2.css - - - sourcemod.2.darkm - - - sourcemod.2.darkm - - - sourcemod.2.darkm - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\mathlib;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(HL2SDK-DARKM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;$(HL2SDK-DARKM)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\mathlib;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(HL2SDK-DARKM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;$(HL2SDK-DARKM)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\mathlib;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(HL2SDK-DARKM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;$(HL2SDK-DARKM)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\mathlib;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(HL2SDKOB)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;$(HL2SDKOB)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\mathlib;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(HL2SDKOB)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;$(HL2SDKOB)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\mathlib;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(HL2SDKOB)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;$(HL2SDKOB)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\mathlib;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(HL2SDKL4D)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;$(HL2SDKL4D)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\mathlib;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(HL2SDKL4D)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;$(HL2SDKL4D)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\mathlib;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(HL2SDKL4D)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;$(HL2SDKL4D)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\mathlib;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(HL2SDKOBVALVE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;$(HL2SDKOBVALVE)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\mathlib;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(HL2SDKCSS)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;$(HL2SDKCSS)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\mathlib;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(HL2SDKOBVALVE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;$(HL2SDKOBVALVE)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\mathlib;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(HL2SDKCSS)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;$(HL2SDKCSS)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\mathlib;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(HL2SDKOBVALVE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;$(HL2SDKOBVALVE)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\mathlib;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(HL2SDKCSS)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;$(HL2SDKCSS)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\mathlib;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(HL2SDKL4D2)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKL4D2)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\mathlib;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(HL2SDKL4D2)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKL4D2)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\mathlib;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(HL2SDKL4D2)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKL4D2)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\mathlib;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(HL2SDK-BGT)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=4;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;$(HL2SDK-BGT)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\mathlib;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(HL2SDK-BGT)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=4;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;$(HL2SDK-BGT)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\mathlib;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(HL2SDK-BGT)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=4;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;$(HL2SDK-BGT)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\mathlib;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(HL2SDK-EYE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=5;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;$(HL2SDK-EYE)\lib\public\mathlib.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\mathlib;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(HL2SDK-EYE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=5;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;$(HL2SDK-EYE)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\mathlib;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(HL2SDK-EYE)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=5;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;$(HL2SDK-EYE)\lib\public\mathlib.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\mathlib;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(HL2SDK-SWARM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=10;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;$(HL2SDK-SWARM)\lib\public\mathlib.lib;$(HL2SDK-SWARM)\lib\public\interfaces.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\mathlib;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(HL2SDK-SWARM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=10;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;$(HL2SDK-SWARM)\lib\public\mathlib.lib;$(HL2SDK-SWARM)\lib\public\interfaces.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\mathlib;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(HL2SDK-SWARM)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=10;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;$(HL2SDK-SWARM)\lib\public\mathlib.lib;$(HL2SDK-SWARM)\lib\public\interfaces.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSGO)\common\protobuf-2.3.0\src;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\engine\protobuf;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\game\shared\csgo\protobuf;$(HL2SDKCSGO)\public\mathlib;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(HL2SDKCSGO)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - _ITERATOR_DEBUG_LEVEL=0;WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\mathlib.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;dbghelp.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSGO)\common\protobuf-2.3.0\src;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\engine\protobuf;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\game\shared\csgo\protobuf;$(HL2SDKCSGO)\public\mathlib;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(HL2SDKCSGO)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - _ITERATOR_DEBUG_LEVEL=0;WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\mathlib.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..\;..\systems;..\..\public;..\..\public\sourcepawn;$(HL2SDKCSGO)\common\protobuf-2.3.0\src;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\engine\protobuf;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\game\shared\csgo\protobuf;$(HL2SDKCSGO)\public\mathlib;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(HL2SDKCSGO)\public\vstdlib;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\public;%(AdditionalIncludeDirectories) - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\mathlib.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;Wsock32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - - - - - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - - - - - - - - - - - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - - - - - - true - true - true - - - - - - - - - - - - - - - - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - \ No newline at end of file diff --git a/core/msvc8/sourcemod_mm.sln b/core/msvc8/sourcemod_mm.sln deleted file mode 100644 index 27d206cc..00000000 --- a/core/msvc8/sourcemod_mm.sln +++ /dev/null @@ -1,41 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sourcemod_mm", "sourcemod_mm.vcproj", "{E39527CD-7CAB-4420-97CC-DA1B93B260BC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|Win32 - CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32 - CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.ActiveCfg = CrazyDebug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.Build.0 = CrazyDebug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.ActiveCfg = CrazyDebug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.Build.0 = CrazyDebug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.ActiveCfg = CrazyDebug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.Build.0 = CrazyDebug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/core/msvc8/sourcemod_mm.vcproj b/core/msvc8/sourcemod_mm.vcproj deleted file mode 100644 index b8206d2c..00000000 --- a/core/msvc8/sourcemod_mm.vcproj +++ /dev/null @@ -1,1563 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/msvc9/sourcemod_mm.sln b/core/msvc9/sourcemod_mm.sln deleted file mode 100644 index f17308b0..00000000 --- a/core/msvc9/sourcemod_mm.sln +++ /dev/null @@ -1,77 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sourcemod_mm", "sourcemod_mm.vcproj", "{E39527CD-7CAB-4420-97CC-DA1B93B260BC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - CrazyDebug - Dark Messiah|Win32 = CrazyDebug - Dark Messiah|Win32 - CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|Win32 - CrazyDebug - Left 4 Dead 2|Win32 = CrazyDebug - Left 4 Dead 2|Win32 - CrazyDebug - Left 4 Dead|Win32 = CrazyDebug - Left 4 Dead|Win32 - CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32 - CrazyDebug - Orange Box Valve|Win32 = CrazyDebug - Orange Box Valve|Win32 - CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32 - Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 - Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 - Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = CrazyDebug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.Build.0 = CrazyDebug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.ActiveCfg = CrazyDebug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.Build.0 = CrazyDebug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = CrazyDebug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = CrazyDebug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = CrazyDebug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.Build.0 = CrazyDebug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.ActiveCfg = CrazyDebug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.Build.0 = CrazyDebug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = CrazyDebug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.Build.0 = CrazyDebug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.ActiveCfg = CrazyDebug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.Build.0 = CrazyDebug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/core/msvc9/sourcemod_mm.vcproj b/core/msvc9/sourcemod_mm.vcproj deleted file mode 100644 index f7528d36..00000000 --- a/core/msvc9/sourcemod_mm.vcproj +++ /dev/null @@ -1,2503 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/sm_srvcmds.cpp b/core/sm_srvcmds.cpp index cf9355e2..0836798c 100644 --- a/core/sm_srvcmds.cpp +++ b/core/sm_srvcmds.cpp @@ -397,11 +397,14 @@ CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle le if (strcmp(args.Arg(1), "log") != 0) { + char filename[PLATFORM_MAX_PATH]; const char *arg = args.Arg(1); - FILE *fp = fopen(arg, "wt"); + g_SourceMod.BuildPath(Path_Game, filename, sizeof(filename), "%s", arg); + + FILE *fp = fopen(filename, "wt"); if (!fp) { - g_RootMenu.ConsolePrint("Could not find file \"%s\"", arg); + g_RootMenu.ConsolePrint("Failed to open \"%s\" for writing", filename); return; } diff --git a/core/sm_stringutil.cpp b/core/sm_stringutil.cpp index 6babf358..a3ec8c83 100644 --- a/core/sm_stringutil.cpp +++ b/core/sm_stringutil.cpp @@ -1180,12 +1180,7 @@ reswitch: { CHECK_ARGS(0); char *str; - int err; - if ((err=pCtx->LocalToString(params[arg], &str)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, "Could not deference string"); - return 0; - } + pCtx->LocalToString(params[arg], &str); AddString(&buf_p, llen, str, width, prec); arg++; break; diff --git a/core/smn_bitbuffer.cpp b/core/smn_bitbuffer.cpp index dfcb5f1c..ac02564d 100644 --- a/core/smn_bitbuffer.cpp +++ b/core/smn_bitbuffer.cpp @@ -194,7 +194,6 @@ static cell_t smn_BfWriteString(IPluginContext *pCtx, const cell_t *params) HandleError herr; HandleSecurity sec; bf_write *pBitBuf; - int err; sec.pOwner = NULL; sec.pIdentity = g_pCoreIdent; @@ -206,11 +205,7 @@ static cell_t smn_BfWriteString(IPluginContext *pCtx, const cell_t *params) } char *str; - if ((err=pCtx->LocalToString(params[2], &str)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToString(params[2], &str); pBitBuf->WriteString(str); diff --git a/core/smn_console.cpp b/core/smn_console.cpp index 6d7e0b96..f4cece35 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -909,11 +909,12 @@ static cell_t sm_ServerCommandEx(IPluginContext *pContext, const cell_t *params) g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); char buffer[1024]; - size_t len = g_SourceMod.FormatString(buffer, sizeof(buffer)-2, pContext, params, 3); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) + size_t len; { - return 0; + DetectExceptions eh(pContext); + len = g_SourceMod.FormatString(buffer, sizeof(buffer)-2, pContext, params, 3); + if (eh.HasException()) + return 0; } /* One byte for null terminator, one for newline */ @@ -965,11 +966,11 @@ static cell_t FakeClientCommandEx(IPluginContext *pContext, const cell_t *params g_SourceMod.SetGlobalTarget(params[1]); char buffer[256]; - g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); - - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; } g_HL2.AddToFakeCliCmdQueue(params[1], GetPlayerUserId(pPlayer->GetEdict()), buffer); diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index d7d99b4b..37a9848c 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -1254,7 +1254,8 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params) is_unsigned = ((pProp->GetFlags() & SPROP_UNSIGNED) == SPROP_UNSIGNED); // This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 if (pProp->GetFlags() & SPROP_VARINT) { bit_count = sizeof(int) * 8; @@ -1352,7 +1353,8 @@ static cell_t SetEntProp(IPluginContext *pContext, const cell_t *params) FIND_PROP_SEND(DPT_Int, "integer"); // This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 if (pProp->GetFlags() & SPROP_VARINT) { bit_count = sizeof(int) * 8; @@ -2156,7 +2158,8 @@ static int32_t SDKEntFlagToSMEntFlag(int flag) #if SOURCE_ENGINE == SE_ALIENSWARM case FL_FREEZING: return ENTFLAG_FREEZING; -#elif SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 +#elif SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 case FL_EP2V_UNKNOWN: return ENTFLAG_EP2V_UNKNOWN1; #endif @@ -2234,7 +2237,8 @@ static int32_t SMEntFlagToSDKEntFlag(int32_t flag) #if SOURCE_ENGINE == SE_ALIENSWARM case ENTFLAG_FREEZING: return FL_FREEZING; -#elif SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 +#elif SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 case ENTFLAG_EP2V_UNKNOWN1: return FL_EP2V_UNKNOWN; #endif diff --git a/core/smn_halflife.cpp b/core/smn_halflife.cpp index c49c6431..41667aff 100644 --- a/core/smn_halflife.cpp +++ b/core/smn_halflife.cpp @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourceMod * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved. @@ -320,13 +320,13 @@ static cell_t PrintToChat(IPluginContext *pContext, const cell_t *params) g_SourceMod.SetGlobalTarget(client); - char buffer[192]; - g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); + char buffer[254]; - /* Check for an error before printing to the client */ - if (pContext->GetLastNativeError() != SP_ERROR_NONE) { - return 0; + DetectExceptions eh(pContext); + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; } if (!g_HL2.TextMsg(client, HUD_PRINTTALK, buffer)) @@ -354,13 +354,13 @@ static cell_t PrintCenterText(IPluginContext *pContext, const cell_t *params) g_SourceMod.SetGlobalTarget(client); - char buffer[192]; - g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); - - /* Check for an error before printing to the client */ - if (pContext->GetLastNativeError() != SP_ERROR_NONE) + char buffer[254]; + { - return 0; + DetectExceptions eh(pContext); + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; } if (!g_HL2.TextMsg(client, HUD_PRINTCENTER, buffer)) @@ -388,13 +388,12 @@ static cell_t PrintHintText(IPluginContext *pContext, const cell_t *params) g_SourceMod.SetGlobalTarget(client); - char buffer[192]; - g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); - - /* Check for an error before printing to the client */ - if (pContext->GetLastNativeError() != SP_ERROR_NONE) + char buffer[254]; { - return 0; + DetectExceptions eh(pContext); + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); + if (eh.HasException()) + return 0; } if (!g_HL2.HintTextMsg(client, buffer)) @@ -499,6 +498,7 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params) case SOURCE_ENGINE_HL2DM: case SOURCE_ENGINE_DODS: case SOURCE_ENGINE_TF2: + case SOURCE_ENGINE_BMS: case SOURCE_ENGINE_SDK2013: return 35; case SOURCE_ENGINE_LEFT4DEAD: diff --git a/core/smn_hudtext.cpp b/core/smn_hudtext.cpp index d1188e51..1a1a2987 100644 --- a/core/smn_hudtext.cpp +++ b/core/smn_hudtext.cpp @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet: * ============================================================================= * SourceMod * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. @@ -415,10 +415,12 @@ static cell_t ShowSyncHudText(IPluginContext *pContext, const cell_t *params) } g_SourceMod.SetGlobalTarget(client); - g_SourceMod.FormatString(message_buffer, sizeof(message_buffer), pContext, params, 3); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) + { - return 0; + DetectExceptions eh(pContext); + g_SourceMod.FormatString(message_buffer, sizeof(message_buffer), pContext, params, 3); + if (eh.HasException()) + return 0; } g_hud_params.channel = s_HudMsgHelpers.AutoSelectChannel(client, obj); @@ -488,10 +490,12 @@ static cell_t ShowHudText(IPluginContext *pContext, const cell_t *params) } g_SourceMod.SetGlobalTarget(client); - g_SourceMod.FormatString(message_buffer, sizeof(message_buffer), pContext, params, 3); - if (pContext->GetLastNativeError() != SP_ERROR_NONE) + { - return 0; + DetectExceptions eh(pContext); + g_SourceMod.FormatString(message_buffer, sizeof(message_buffer), pContext, params, 3); + if (eh.HasException()) + return 0; } if (params[2] == -1) diff --git a/core/smn_protobuf.cpp b/core/smn_protobuf.cpp index 2485aabe..5552e16f 100644 --- a/core/smn_protobuf.cpp +++ b/core/smn_protobuf.cpp @@ -52,13 +52,8 @@ // Assumes message field name is param 2, gets as strField #define GET_FIELD_NAME_OR_ERR() \ - int err; \ char *strField; \ - if ((err=pCtx->LocalToString(params[2], &strField)) != SP_ERROR_NONE) \ - { \ - pCtx->ThrowNativeErrorEx(err, NULL); \ - return 0; \ - } + pCtx->LocalToString(params[2], &strField); static cell_t smn_PbReadInt(IPluginContext *pCtx, const cell_t *params) { @@ -387,11 +382,7 @@ static cell_t smn_PbSetString(IPluginContext *pCtx, const cell_t *params) GET_FIELD_NAME_OR_ERR(); char *strValue; - if ((err=pCtx->LocalToString(params[3], &strValue)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToString(params[3], &strValue); int index = params[0] >= 4 ? params[4] : -1; if (index < 0) @@ -418,11 +409,7 @@ static cell_t smn_PbSetColor(IPluginContext *pCtx, const cell_t *params) GET_FIELD_NAME_OR_ERR(); cell_t *clrParams; - if ((err=pCtx->LocalToPhysAddr(params[3], &clrParams)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToPhysAddr(params[3], &clrParams); Color clr( clrParams[0], @@ -455,11 +442,7 @@ static cell_t smn_PbSetAngle(IPluginContext *pCtx, const cell_t *params) GET_FIELD_NAME_OR_ERR(); cell_t *angParams; - if ((err=pCtx->LocalToPhysAddr(params[3], &angParams)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToPhysAddr(params[3], &angParams); QAngle ang( sp_ctof(angParams[0]), @@ -491,11 +474,7 @@ static cell_t smn_PbSetVector(IPluginContext *pCtx, const cell_t *params) GET_FIELD_NAME_OR_ERR(); cell_t *vecParams; - if ((err=pCtx->LocalToPhysAddr(params[3], &vecParams)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToPhysAddr(params[3], &vecParams); Vector vec( sp_ctof(vecParams[0]), @@ -527,11 +506,7 @@ static cell_t smn_PbSetVector2D(IPluginContext *pCtx, const cell_t *params) GET_FIELD_NAME_OR_ERR(); cell_t *vecParams; - if ((err=pCtx->LocalToPhysAddr(params[3], &vecParams)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToPhysAddr(params[3], &vecParams); Vector2D vec( sp_ctof(vecParams[0]), @@ -602,11 +577,7 @@ static cell_t smn_PbAddString(IPluginContext *pCtx, const cell_t *params) GET_FIELD_NAME_OR_ERR(); char *strValue; - if ((err=pCtx->LocalToString(params[3], &strValue)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToString(params[3], &strValue); if (!msg->AddString(strField, strValue)) { @@ -622,11 +593,7 @@ static cell_t smn_PbAddColor(IPluginContext *pCtx, const cell_t *params) GET_FIELD_NAME_OR_ERR(); cell_t *clrParams; - if ((err=pCtx->LocalToPhysAddr(params[3], &clrParams)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToPhysAddr(params[3], &clrParams); Color clr( clrParams[0], @@ -648,11 +615,7 @@ static cell_t smn_PbAddAngle(IPluginContext *pCtx, const cell_t *params) GET_FIELD_NAME_OR_ERR(); cell_t *angParams; - if ((err=pCtx->LocalToPhysAddr(params[3], &angParams)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToPhysAddr(params[3], &angParams); QAngle ang( sp_ctof(angParams[0]), @@ -673,11 +636,7 @@ static cell_t smn_PbAddVector(IPluginContext *pCtx, const cell_t *params) GET_FIELD_NAME_OR_ERR(); cell_t *vecParams; - if ((err=pCtx->LocalToPhysAddr(params[3], &vecParams)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToPhysAddr(params[3], &vecParams); Vector vec( sp_ctof(vecParams[0]), @@ -698,11 +657,7 @@ static cell_t smn_PbAddVector2D(IPluginContext *pCtx, const cell_t *params) GET_FIELD_NAME_OR_ERR(); cell_t *vecParams; - if ((err=pCtx->LocalToPhysAddr(params[3], &vecParams)) != SP_ERROR_NONE) - { - pCtx->ThrowNativeErrorEx(err, NULL); - return 0; - } + pCtx->LocalToPhysAddr(params[3], &vecParams); Vector2D vec( sp_ctof(vecParams[0]), diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index 5d68eb1d..095e04ef 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -54,6 +54,7 @@ ILibrary *g_pJIT = NULL; SourceHook::String g_BaseDir; ISourcePawnEngine *g_pSourcePawn = NULL; ISourcePawnEngine2 *g_pSourcePawn2 = NULL; +ISourcePawnEnvironment *g_pPawnEnv = NULL; IdentityToken_t *g_pCoreIdent = NULL; IForward *g_pOnMapEnd = NULL; IGameConfig *g_pGameConf = NULL; @@ -61,10 +62,6 @@ bool g_Loaded = false; bool sm_show_debug_spew = false; bool sm_disable_jit = false; -typedef ISourcePawnEngine *(*GET_SP_V1)(); -typedef ISourcePawnEngine2 *(*GET_SP_V2)(); -typedef void (*NOTIFYSHUTDOWN)(); - #ifdef PLATFORM_WINDOWS ConVar sm_basepath("sm_basepath", "addons\\sourcemod", 0, "SourceMod base path (set via command line)"); #elif defined PLATFORM_LINUX || defined PLATFORM_APPLE @@ -73,18 +70,17 @@ ConVar sm_basepath("sm_basepath", "addons/sourcemod", 0, "SourceMod base path (s void ShutdownJIT() { - NOTIFYSHUTDOWN notify = (NOTIFYSHUTDOWN)g_pJIT->GetSymbolAddress("NotifyShutdown"); - if (notify) - { - notify(); - } + if (g_pPawnEnv) { + g_pPawnEnv->Shutdown(); + delete g_pPawnEnv; - if (g_pSourcePawn2 != NULL) - { - g_pSourcePawn2->Shutdown(); + g_pPawnEnv = NULL; + g_pSourcePawn2 = NULL; + g_pSourcePawn = NULL; } g_pJIT->CloseLibrary(); + g_pJIT = NULL; } SourceModBase::SourceModBase() @@ -176,9 +172,6 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late return false; } - /* Initialize CoreConfig to get the SourceMod base path properly - this parses core.cfg */ - g_CoreConfig.Initialize(); - /* There will always be a path by this point, since it was force-set above. */ m_GotBasePath = true; @@ -202,51 +195,35 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late return false; } - GET_SP_V1 getv1 = (GET_SP_V1)g_pJIT->GetSymbolAddress("GetSourcePawnEngine1"); - GET_SP_V2 getv2 = (GET_SP_V2)g_pJIT->GetSymbolAddress("GetSourcePawnEngine2"); + GetSourcePawnFactoryFn factoryFn = + (GetSourcePawnFactoryFn)g_pJIT->GetSymbolAddress("GetSourcePawnFactory"); - if (getv1 == NULL) - { + if (!factoryFn) { if (error && maxlength) - { - snprintf(error, maxlength, "JIT is too old; upgrade SourceMod"); - } - ShutdownJIT(); - return false; - } - else if (getv2 == NULL) - { - if (error && maxlength) - { - snprintf(error, maxlength, "JIT is too old; upgrade SourceMod"); - } + snprintf(error, maxlength, "SourcePawn library is out of date"); ShutdownJIT(); return false; } - g_pSourcePawn = getv1(); - g_pSourcePawn2 = getv2(); - - if (g_pSourcePawn2->GetAPIVersion() < 3) - { - g_pSourcePawn2 = NULL; + ISourcePawnFactory *factory = factoryFn(SOURCEPAWN_API_VERSION); + if (!factory) { if (error && maxlength) - { - snprintf(error, maxlength, "JIT version is out of date"); - } + snprintf(error, maxlength, "SourcePawn library is out of date"); + ShutdownJIT(); return false; } - if (!g_pSourcePawn2->Initialize()) - { - g_pSourcePawn2 = NULL; + g_pPawnEnv = factory->NewEnvironment(); + if (!g_pPawnEnv) { if (error && maxlength) - { - snprintf(error, maxlength, "JIT could not be initialized"); - } + snprintf(error, maxlength, "Could not create a SourcePawn environment!"); + ShutdownJIT(); return false; } + g_pSourcePawn = g_pPawnEnv->APIv1(); + g_pSourcePawn2 = g_pPawnEnv->APIv2(); + g_pSourcePawn2->SetDebugListener(logicore.debugger); if (sm_disable_jit) @@ -276,6 +253,9 @@ void SourceModBase::StartSourceMod(bool late) InitLogicBridge(); + /* Initialize CoreConfig to get the SourceMod base path properly - this parses core.cfg */ + g_CoreConfig.Initialize(); + /* Notify! */ SMGlobalClass *pBase = SMGlobalClass::head; while (pBase) @@ -340,6 +320,8 @@ void SourceModBase::StartSourceMod(bool late) static bool g_LevelEndBarrier = false; bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background) { + g_Players.MaxPlayersChanged(); + /* If we're not loaded... */ if (!g_Loaded) { diff --git a/extensions/bintools/Makefile b/extensions/bintools/Makefile deleted file mode 100644 index 683e57bb..00000000 --- a/extensions/bintools/Makefile +++ /dev/null @@ -1,191 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -SRCDS_BASE = ~/srcds -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -HL2SDK_L4D2 = ../../../hl2sdk-l4d2 -MMSOURCE17 = ../../../mmsource-central - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = bintools - -OBJECTS = sdk/smsdk_ext.cpp extension.cpp jit_call.cpp CallWrapper.cpp CallMaker.cpp HookWrapper.cpp jit_hook.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - INCLUDE += -I$(MMSOURCE17)/core -I$(MMSOURCE17)/core/sourcehook - SRCDS = $(SRCDS_BASE) - GAMEFIX = 1.ep1 - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - GAMEFIX = 2.ep2 - override ENGSET = true - USEMETA = true - CFLAGS += -DHOOKING_ENABLED -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=4 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - GAMEFIX = 2.ep2v - override ENGSET = true - USEMETA = true - CFLAGS += -DHOOKING_ENABLED -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=5 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d - GAMEFIX = 2.l4d - override ENGSET = true - USEMETA = true - CFLAGS += -DHOOKING_ENABLED -endif -ifeq "$(ENGINE)" "left4dead2" - HL2SDK = $(HL2SDK_L4D2) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=6 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/left4dead2_demo - GAMEFIX = 2.l4d2 - override ENGSET = true - USEMETA = true - CFLAGS += -DHOOKING_ENABLED -endif - -ifeq "$(USEMETA)" "true" -ifeq "$(ENGINE)" "left4dead2" - LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_linux.so tier0_linux.so -else - LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -endif - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn \ - -I$(SMSDK)/public/extensions -I$(SMSDK)/public/jit -I$(SMSDK)/public/jit/x86 - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -DSE_LEFT4DEAD2=6 -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/extensions -I$(SMSDK)/public/jit \ - -I$(SMSDK)/public/jit/x86 -I$(SMSDK)/public/sourcepawn -endif - -LINK += -m32 -ldl -lm - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -mfpmath=sse \ - -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -else - BIN_DIR := $(BIN_DIR).original -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.$(GAMEFIX).dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.$(GAMEFIX).so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - if [ "$(USEMETA)" = "true" ]; then \ - if [ "$(ENGINE)" = "left4dead2" ]; then \ - ln -sf $(SRCDS)/bin/vstdlib_linux.so vstdlib_linux.so; \ - ln -sf $(SRCDS)/bin/tier0_linux.so tier0_linux.so; \ - else \ - ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \ - ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \ - fi \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) - diff --git a/extensions/bintools/msvc10/bintools.sln b/extensions/bintools/msvc10/bintools.sln deleted file mode 100644 index 69dbc5f3..00000000 --- a/extensions/bintools/msvc10/bintools.sln +++ /dev/null @@ -1,56 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bintools", "bintools.vcxproj", "{E38F65D9-74B2-4373-B46A-DBB76F579F98}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 - Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 - Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/bintools/msvc10/bintools.vcxproj b/extensions/bintools/msvc10/bintools.vcxproj deleted file mode 100644 index 0b9afb35..00000000 --- a/extensions/bintools/msvc10/bintools.vcxproj +++ /dev/null @@ -1,154 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {E38F65D9-74B2-4373-B46A-DBB76F579F98} - bintools - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - bintools.ext - - - bintools.ext - - - - - - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\jit;..\..\..\public\jit\x86;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;BINTOOLS_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD;HOOKING_ENABLED;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - - - ..\..\..\public - - - %(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - - - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\jit;..\..\..\public\jit\x86;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;BINTOOLS_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;HOOKING_ENABLED;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - - - ..\..\..\public - - - %(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/bintools/msvc10/bintools.vcxproj.filters b/extensions/bintools/msvc10/bintools.vcxproj.filters deleted file mode 100644 index 40696071..00000000 --- a/extensions/bintools/msvc10/bintools.vcxproj.filters +++ /dev/null @@ -1,88 +0,0 @@ - - - - - {0318D835-E129-4fe0-9B9C-C810AC179F31} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {9021A2EF-600E-4028-AE3E-9DDA4C94264C} - h;hpp;hxx;hm;inl;inc;xsd - - - {C06F7BFF-18EE-4994-8572-D6383011354B} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {7BD12831-E179-4961-A3B0-BA9FCF311C7E} - - - {2B033553-ECC7-42cc-AD11-D1D985D8BC5A} - h;hpp;hxx;hm;inl;inc;xsd - - - {F70EA5AC-224C-448f-A72D-11C2D06208B3} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {6183251D-B1E4-4cc6-93B2-A0111B2115BA} - - - {7DE81EA3-99D9-4f34-823A-B314791F3514} - - - - - Source Files - - - BinTools\Source Files - - - BinTools\Source Files - - - BinTools\Source Files - - - BinTools\Source Files - - - BinTools\Source Files - - - SourceMod SDK - - - - - Header Files - - - Resource Files - - - BinTools\Header Files - - - BinTools\Header Files - - - BinTools\Header Files - - - BinTools\Header Files - - - SourceMod SDK - - - SourceMod SDK - - - - - Resource Files - - - \ No newline at end of file diff --git a/extensions/bintools/msvc8/bintools.sln b/extensions/bintools/msvc8/bintools.sln deleted file mode 100644 index 61d64d98..00000000 --- a/extensions/bintools/msvc8/bintools.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bintools", "bintools.vcproj", "{E38F65D9-74B2-4373-B46A-DBB76F579F98}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/bintools/msvc8/bintools.vcproj b/extensions/bintools/msvc8/bintools.vcproj deleted file mode 100644 index 065d5798..00000000 --- a/extensions/bintools/msvc8/bintools.vcproj +++ /dev/null @@ -1,283 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/bintools/msvc9/bintools.sln b/extensions/bintools/msvc9/bintools.sln deleted file mode 100644 index 1cb74301..00000000 --- a/extensions/bintools/msvc9/bintools.sln +++ /dev/null @@ -1,56 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bintools", "bintools.vcproj", "{E38F65D9-74B2-4373-B46A-DBB76F579F98}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 - Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 - Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/bintools/msvc9/bintools.vcproj b/extensions/bintools/msvc9/bintools.vcproj deleted file mode 100644 index 3fbea1eb..00000000 --- a/extensions/bintools/msvc9/bintools.vcproj +++ /dev/null @@ -1,1251 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/clientprefs/Makefile b/extensions/clientprefs/Makefile deleted file mode 100644 index ea660db6..00000000 --- a/extensions/clientprefs/Makefile +++ /dev/null @@ -1,156 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -SRCDS_BASE = ~/srcds -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -MMSOURCE17 = ../../../mmsource-1.7 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = clientprefs - -#Uncomment for Metamod: Source enabled extension -#USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp extension.cpp query.cpp cookie.cpp natives.cpp menus.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - SRCDS = $(SRCDS_BASE) - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=4 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=5 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d - override ENGSET = true -endif - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \ - -I$(MMSOURCE17)/core/sourcehook -endif - -LINK += -m32 -ldl -lm - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ - -Wno-unused -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -Wno-uninitialized -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \ - ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/clientprefs/msvc10/clientprefs.sln b/extensions/clientprefs/msvc10/clientprefs.sln deleted file mode 100644 index e4809836..00000000 --- a/extensions/clientprefs/msvc10/clientprefs.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clientprefs", "clientprefs.vcxproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/clientprefs/msvc10/clientprefs.vcxproj b/extensions/clientprefs/msvc10/clientprefs.vcxproj deleted file mode 100644 index 971732aa..00000000 --- a/extensions/clientprefs/msvc10/clientprefs.vcxproj +++ /dev/null @@ -1,141 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {B3E797CF-4E77-4C9D-B8A8-7589B6902206} - clientprefs - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - clientprefs.ext - - - clientprefs.ext - - - - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions\" - - - - - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions\" - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/clientprefs/msvc10/clientprefs.vcxproj.filters b/extensions/clientprefs/msvc10/clientprefs.vcxproj.filters deleted file mode 100644 index b8556674..00000000 --- a/extensions/clientprefs/msvc10/clientprefs.vcxproj.filters +++ /dev/null @@ -1,65 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {31958233-BB2D-4e41-A8F9-CE8A4684F436} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - SourceMod SDK - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - SourceMod SDK - - - SourceMod SDK - - - - - Resource Files - - - \ No newline at end of file diff --git a/extensions/clientprefs/msvc8/clientprefs.sln b/extensions/clientprefs/msvc8/clientprefs.sln deleted file mode 100644 index 149aec17..00000000 --- a/extensions/clientprefs/msvc8/clientprefs.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clientprefs", "clientprefs.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/clientprefs/msvc8/clientprefs.vcproj b/extensions/clientprefs/msvc8/clientprefs.vcproj deleted file mode 100644 index 855e1e8b..00000000 --- a/extensions/clientprefs/msvc8/clientprefs.vcproj +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/clientprefs/msvc9/clientprefs.sln b/extensions/clientprefs/msvc9/clientprefs.sln deleted file mode 100644 index 1532d69a..00000000 --- a/extensions/clientprefs/msvc9/clientprefs.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clientprefs", "clientprefs.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/clientprefs/msvc9/clientprefs.vcproj b/extensions/clientprefs/msvc9/clientprefs.vcproj deleted file mode 100644 index 5b4fc565..00000000 --- a/extensions/clientprefs/msvc9/clientprefs.vcproj +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/cstrike/Makefile b/extensions/cstrike/Makefile deleted file mode 100644 index 57b8536a..00000000 --- a/extensions/cstrike/Makefile +++ /dev/null @@ -1,198 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_CSS = ../../../hl2sdk-css -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -HL2SDK_L4D2 = ../../../hl2sdk-l4d2 -HL2SDK_CSGO = ../../../hl2sdk-csgo -MMSOURCE19 = ../../../mmsource-1.9 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = game.cstrike - -#Uncomment for Metamod: Source enabled extension -USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp timeleft.cpp forwards.cpp CDetour/detours.cpp asm/asm.c - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false - -# Check for valid list of engines -ifneq (,$(filter original orangebox css orangeboxvalve left4dead left4dead2,$(ENGINE))) - override ENGSET = true -endif - -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - CFLAGS += -DSOURCE_ENGINE=1 - GAMEFIX = 1.ep1 -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - CFLAGS += -DSOURCE_ENGINE=3 - GAMEFIX = 2.ep2 -endif -ifeq "$(ENGINE)" "css" - HL2SDK = $(HL2SDK_CSS) - CFLAGS += -DSOURCE_ENGINE=4 - GAMEFIX = 2.css -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - CFLAGS += -DSOURCE_ENGINE=5 - GAMEFIX = 2.ep2v -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - CFLAGS += -DSOURCE_ENGINE=6 - GAMEFIX = 2.l4d -endif -ifeq "$(ENGINE)" "left4dead2" - HL2SDK = $(HL2SDK_L4D2) - CFLAGS += -DSOURCE_ENGINE=7 - GAMEFIX = 2.l4d2 -endif -ifeq "$(ENGINE)" "csgo" - HL2SDK = $(HL2SDK_CSGO) - CFLAGS += -DSOURCE_ENGINE=8 - GAMEFIX = 2.csgo -endif - -HL2PUB = $(HL2SDK)/public - -ifeq "$(ENGINE)" "original" - INCLUDE += -I$(HL2SDK)/public/dlls - METAMOD = $(MMSOURCE19)/core-legacy -else - INCLUDE += -I$(HL2SDK)/public/game/server - METAMOD = $(MMSOURCE19)/core -endif - -OS := $(shell uname -s) - -ifeq "$(OS)" "Darwin" - LIB_EXT = dylib - HL2LIB = $(HL2SDK)/lib/mac -else - LIB_EXT = so - ifeq "$(ENGINE)" "original" - HL2LIB = $(HL2SDK)/linux_sdk - else - HL2LIB = $(HL2SDK)/lib/linux - endif -endif - -# if ENGINE is orig, OB, or L4D -ifneq (,$(filter original orangebox left4dead,$(ENGINE))) - LIB_SUFFIX = _i486.$(LIB_EXT) -else - LIB_PREFIX = lib - LIB_SUFFIX = .$(LIB_EXT) -endif - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) $(LIB_PREFIX)tier0$(LIB_SUFFIX) - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/extensions \ - -I$(SMSDK)/public/sourcepawn - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_CSS=4 -DSE_ORANGEBOXVALVE=5 \ - -DSE_LEFT4DEAD=6 -DSE_LEFT4DEAD2=7 -DSE_CSGO=8 -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -endif - -LINK += -m32 -ldl -lm - -CFLAGS += -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \ - -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -BINARY = $(PROJECT).ext.$(GAMEFIX).$(LIB_EXT) - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -ifeq "$(OS)" "Darwin" - LIB_EXT = dylib - CFLAGS += -isysroot /Developer/SDKs/MacOSX10.5.sdk - LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5 -else - LIB_EXT = so - CFLAGS += -D_LINUX - LINK += -shared -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - mkdir -p $(BIN_DIR)/CDetour - mkdir -p $(BIN_DIR)/asm - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(HL2LIB)/$(LIB_PREFIX)vstdlib$(LIB_SUFFIX); \ - ln -sf $(HL2LIB)/$(LIB_PREFIX)tier0$(LIB_SUFFIX); \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply one of the following values for ENGINE:"; \ - echo "left4dead2, left4dead, orangeboxvalve, css, orangebox, or original"; \ - exit 1; \ - fi - -extension: check $(OBJ_BIN) - $(CPP) $(INCLUDE) $(OBJ_BIN) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/cstrike/forwards.cpp b/extensions/cstrike/forwards.cpp index 9d6bb150..48213f02 100644 --- a/extensions/cstrike/forwards.cpp +++ b/extensions/cstrike/forwards.cpp @@ -61,9 +61,21 @@ DETOUR_DECL_MEMBER1(DetourHandleBuy, int, const char *, weapon) #if SOURCE_ENGINE != SE_CSGO DETOUR_DECL_MEMBER0(DetourWeaponPrice, int) +#elif defined(WIN32) +DETOUR_DECL_MEMBER2(DetourWeaponPrice, int, CEconItemView *, pEconItem, int, iUnknown) +#else +DETOUR_DECL_MEMBER3(DetourWeaponPrice, int, CEconItemView *, pEconItem, int, iUnknown, float, fUnknown) +#endif { - int price = DETOUR_MEMBER_CALL(DetourWeaponPrice)(); +#if SOURCE_ENGINE != SE_CSGO + int price = DETOUR_MEMBER_CALL(DetourWeaponPrice)(); +#elif defined(WIN32) + int price = DETOUR_MEMBER_CALL(DetourWeaponPrice)(pEconItem, iUnknown); +#else + int price = DETOUR_MEMBER_CALL(DetourWeaponPrice)(pEconItem, iUnknown, fUnknown); +#endif + if (lastclient == -1) return price; @@ -71,19 +83,6 @@ DETOUR_DECL_MEMBER0(DetourWeaponPrice, int) return CallPriceForward(lastclient, weapon_name, price); } -#else -DETOUR_DECL_MEMBER2(DetourWeaponPrice, int, const char *, szAttribute, CEconItemView *, pEconItem) -{ - int price = DETOUR_MEMBER_CALL(DetourWeaponPrice)(szAttribute, pEconItem); - - if(lastclient == -1 || strcmp(szAttribute, "in game price") != 0) - return price; - - const char *weapon_name = reinterpret_cast(this+weaponNameOffset); - - return CallPriceForward(lastclient, weapon_name, price); -} -#endif #if SOURCE_ENGINE != SE_CSGO || !defined(WIN32) DETOUR_DECL_MEMBER2(DetourTerminateRound, void, float, delay, int, reason) @@ -178,7 +177,7 @@ DETOUR_DECL_MEMBER3(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, bDrop g_pCSWeaponDropForward->Execute(&result); - if (result >= Pl_Continue) + if (result == Pl_Continue) { #if SOURCE_ENGINE == SE_CSGO DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, vec, unknown); @@ -201,8 +200,15 @@ bool CreateWeaponPriceDetour() } } -#if SOURCE_ENGINE == SE_CSGO - DWeaponPrice = DETOUR_CREATE_MEMBER(DetourWeaponPrice, "GetAttributeInt"); +#if SOURCE_ENGINE == SE_CSGO && defined(WIN32) + void *pGetWeaponPriceAddress = GetWeaponPriceFunction(); + + if(!pGetWeaponPriceAddress) + { + g_pSM->LogError(myself, "GetWeaponPrice detour could not be initialized - Disabled OnGetWeaponPrice forward."); + } + + DWeaponPrice = DETOUR_CREATE_MEMBER(DetourWeaponPrice, pGetWeaponPriceAddress); #else DWeaponPrice = DETOUR_CREATE_MEMBER(DetourWeaponPrice, "GetWeaponPrice"); #endif diff --git a/extensions/cstrike/msvc10/cstrike.sln b/extensions/cstrike/msvc10/cstrike.sln deleted file mode 100644 index d0b5ed72..00000000 --- a/extensions/cstrike/msvc10/cstrike.sln +++ /dev/null @@ -1,41 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cstrike", "cstrike.vcxproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - Episode1|Win32 = Debug - Episode1|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Release - CS GO|Win32 = Release - CS GO|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode1|Win32.ActiveCfg = Debug - Episode1|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode1|Win32.Build.0 = Debug - Episode1|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/cstrike/msvc10/cstrike.vcxproj b/extensions/cstrike/msvc10/cstrike.vcxproj deleted file mode 100644 index 67a0a0b0..00000000 --- a/extensions/cstrike/msvc10/cstrike.vcxproj +++ /dev/null @@ -1,662 +0,0 @@ - - - - - Debug - CS GO - Win32 - - - Debug - CSS - Win32 - - - Debug - Episode1 - Win32 - - - Debug - Old Metamod - Win32 - - - Debug - Orange Box Valve - Win32 - - - Debug - Orange Box - Win32 - - - Release - CS GO - Win32 - - - Release - CSS - Win32 - - - Release - Episode 1 - Win32 - - - Release - Old Metamod - Win32 - - - Release - Orange Box Valve - Win32 - - - Release - Orange Box - Win32 - - - - {18B5ED38-DBB7-47B2-8500-5648B8C1263B} - cstrike - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - true - true - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - false - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - game.cstrike.ext.2.csgo - - - game.cstrike.ext.2.ep1 - - - game.cstrike.ext.1.ep1 - - - game.cstrike.ext.2.ep2 - - - game.cstrike.ext.2.ep2v - - - game.cstrike.ext.2.css - - - game.cstrike.ext.2.csgo - - - game.cstrike.ext.2.ep1 - - - game.cstrike.ext.1.ep1 - - - game.cstrike.ext.2.ep2 - - - game.cstrike.ext.2.ep2v - - - game.cstrike.ext.2.css - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/cstrike/msvc10/cstrike.vcxproj.filters b/extensions/cstrike/msvc10/cstrike.vcxproj.filters deleted file mode 100644 index b33e18f2..00000000 --- a/extensions/cstrike/msvc10/cstrike.vcxproj.filters +++ /dev/null @@ -1,87 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {31958233-BB2D-4e41-A8F9-CE8A4684F436} - - - {bed40a0d-9cf0-408e-b407-b40d3e72ccd5} - - - {e6b64c8f-79f3-48fe-a66f-caaafc86710c} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - SourceMod SDK - - - asm - - - CDetour - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - SourceMod SDK - - - SourceMod SDK - - - asm - - - CDetour - - - CDetour - - - \ No newline at end of file diff --git a/extensions/cstrike/natives.cpp b/extensions/cstrike/natives.cpp index f6f07ea1..1b4ebcf5 100644 --- a/extensions/cstrike/natives.cpp +++ b/extensions/cstrike/natives.cpp @@ -419,6 +419,7 @@ static cell_t CS_GetTranslatedWeaponAlias(IPluginContext *pContext, const cell_t static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params) { + if (!IsValidWeaponID(params[2])) return pContext->ThrowNativeError("Invalid WeaponID passed for this game"); @@ -426,6 +427,7 @@ static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params) //Hard code return values for weapons that dont call GetWeaponPrice and always use default value. #if SOURCE_ENGINE == SE_CSGO + if (id == WEAPON_C4 || id == WEAPON_KNIFE || id == WEAPON_KNIFE_GG) return 0; #else @@ -458,23 +460,49 @@ static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params) #if SOURCE_ENGINE == SE_CSGO static ICallWrapper *pWrapper = NULL; +#if defined(WIN32) + if(!pWrapper) + { + void *pGetWeaponPrice = GetWeaponPriceFunction(); + if(!pGetWeaponPrice) + { + return pContext->ThrowNativeError("Failed to locate function"); + } + + PassInfo pass[2]; + PassInfo ret; + pass[0].flags = PASSFLAG_BYVAL; + pass[0].type = PassType_Basic; + pass[0].size = sizeof(CEconItemView *); + pass[1].flags = PASSFLAG_BYVAL; + pass[1].type = PassType_Basic; + pass[1].size = sizeof(int); + ret.flags = PASSFLAG_BYVAL; + ret.type = PassType_Basic; + ret.size = sizeof(int); + pWrapper = g_pBinTools->CreateCall(pGetWeaponPrice, CallConv_ThisCall, &ret, pass, 2); + } +#else if (!pWrapper) { - REGISTER_NATIVE_ADDR("GetAttributeInt", - PassInfo pass[2]; \ + REGISTER_NATIVE_ADDR("GetWeaponPrice", + PassInfo pass[3]; \ PassInfo ret; \ pass[0].flags = PASSFLAG_BYVAL; \ pass[0].type = PassType_Basic; \ - pass[0].size = sizeof(char *); \ + pass[0].size = sizeof(CEconItemView *); \ pass[1].flags = PASSFLAG_BYVAL; \ pass[1].type = PassType_Basic; \ - pass[1].size = sizeof(CEconItemView *); \ + pass[1].size = sizeof(int); \ + pass[2].flags = PASSFLAG_BYVAL; \ + pass[2].type = PassType_Float; \ + pass[2].size = sizeof(float); \ ret.flags = PASSFLAG_BYVAL; \ ret.type = PassType_Basic; \ ret.size = sizeof(int); \ - pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, &ret, pass, 2)) + pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, &ret, pass, 3)) } - +#endif // Get a CEconItemView for the m4 // Found in CCSPlayer::HandleCommand_Buy_Internal // Linux a1 - CCSPlayer *pEntity, v5 - Player Team, a3 - ItemLoadoutSlot -1 use default loadoutslot: @@ -552,14 +580,22 @@ static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params) pGetView->Execute(vstk_view, &view); } - unsigned char vstk[sizeof(void *) * 2 + sizeof(char *)]; +#if defined(WIN32) + unsigned char vstk[sizeof(void *) * 2 + sizeof(int)]; +#else + unsigned char vstk[sizeof(void *) * 2 + sizeof(int) + sizeof(float)]; +#endif unsigned char *vptr = vstk; *(void **)vptr = info; vptr += sizeof(void *); - *(const char **)vptr = "in game price"; - vptr += sizeof(const char *); *(CEconItemView **)vptr = view; + vptr += sizeof(CEconItemView *); + *(int *)vptr = 0; +#if !defined(WIN32) + vptr += sizeof(int); + *(float *)vptr = 1.0; +#endif int price = 0; pWrapper->Execute(vstk, &price); diff --git a/extensions/cstrike/util_cstrike.cpp b/extensions/cstrike/util_cstrike.cpp index ad1c4b7c..58e0573f 100644 --- a/extensions/cstrike/util_cstrike.cpp +++ b/extensions/cstrike/util_cstrike.cpp @@ -229,6 +229,56 @@ const char *WeaponIDToAlias(int weaponID) #endif return alias; } + +#if SOURCE_ENGINE == SE_CSGO && defined(WIN32) +void *GetWeaponPriceFunction() +{ + static void *pGetWeaponPriceAddress = NULL; + + if(pGetWeaponPriceAddress == NULL) + { + void *pAddress = NULL; + int offset = 0; + int callOffset = 0; + const char* byteCheck = NULL; + + if(!g_pGameConf->GetMemSig("GetWeaponPrice", &pAddress) || pAddress == NULL) + { + g_pSM->LogError(myself, "Failed to get GetWeaponPrice address."); + return NULL; + } + + if(!g_pGameConf->GetOffset("GetWeaponPriceFunc", &offset)) + { + g_pSM->LogError(myself, "Failed to get GetWeaponPriceFunc offset."); + return NULL; + } + + byteCheck = g_pGameConf->GetKeyValue("GetWeaponPriceByteCheck"); + + if(byteCheck == NULL) + { + g_pSM->LogError(myself, "Failed to get GetWeaponPriceByteCheck keyvalue."); + return NULL; + } + + uint8_t iByte = strtoul(byteCheck, NULL, 16); + + if(iByte != *(uint8_t *)((intptr_t)pAddress + (offset-1))) + { + g_pSM->LogError(myself, "GetWeaponPrice Byte check failed."); + return NULL; + } + + callOffset = *(uint32_t *)((intptr_t)pAddress + offset); + + pGetWeaponPriceAddress = (void *)((intptr_t)pAddress + offset + callOffset + sizeof(int)); + } + + return pGetWeaponPriceAddress; +} +#endif + int GetRealWeaponID(int weaponId) { #if SOURCE_ENGINE == SE_CSGO diff --git a/extensions/cstrike/util_cstrike.h b/extensions/cstrike/util_cstrike.h index 9f5445d4..160ca805 100644 --- a/extensions/cstrike/util_cstrike.h +++ b/extensions/cstrike/util_cstrike.h @@ -165,4 +165,6 @@ int GetFakeWeaponID(int weaponId); bool IsValidWeaponID(int weaponId); +void *GetWeaponPriceFunction(); + #endif diff --git a/extensions/curl/Makefile b/extensions/curl/Makefile deleted file mode 100644 index d029a11b..00000000 --- a/extensions/curl/Makefile +++ /dev/null @@ -1,160 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -SRCDS_BASE = ~/srcds -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -MMSOURCE17 = ../../../mmsource-1.7 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = webternet - -#Uncomment for Metamod: Source enabled extension -#USEMETA = true - -OBJECTS = \ - sdk/smsdk_ext.cpp \ - extension.cpp \ - curlapi.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - SRCDS = $(SRCDS_BASE) - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=4 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=5 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d - override ENGSET = true -endif - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -endif - -INCLUDE += -I$(SMSDK)/public/extensions -Icurl-src/include - -LINK += -m32 -lm -ldl -lrt curl-src/Release/lib/.libs/libcurl.a - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ - -Wno-unused -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \ - ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/curl/msvc9/curl.sln b/extensions/curl/msvc9/curl.sln deleted file mode 100644 index 43615cb0..00000000 --- a/extensions/curl/msvc9/curl.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "curl", "curl.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/curl/msvc9/curl.vcproj b/extensions/curl/msvc9/curl.vcproj deleted file mode 100644 index 1274a621..00000000 --- a/extensions/curl/msvc9/curl.vcproj +++ /dev/null @@ -1,250 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/geoip/Makefile b/extensions/geoip/Makefile deleted file mode 100644 index b3fbcbae..00000000 --- a/extensions/geoip/Makefile +++ /dev/null @@ -1,155 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -SRCDS_BASE = ~/srcds -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -MMSOURCE17 = ../../../mmsource-1.7 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = geoip - -#Uncomment for Metamod: Source enabled extension -#USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp extension.cpp GeoIP.c - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - SRCDS = $(SRCDS_BASE) - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=4 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=5 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d - override ENGSET = true -endif - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -endif - -LINK += -m32 -ldl -lm - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -mfpmath=sse \ - -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \ - ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/geoip/msvc8/geoip.sln b/extensions/geoip/msvc8/geoip.sln deleted file mode 100644 index 2fb7770a..00000000 --- a/extensions/geoip/msvc8/geoip.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geoip", "geoip.vcproj", "{698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Debug|Win32.ActiveCfg = Debug|Win32 - {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Debug|Win32.Build.0 = Debug|Win32 - {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Release|Win32.ActiveCfg = Release|Win32 - {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/geoip/msvc8/geoip.vcproj b/extensions/geoip/msvc8/geoip.vcproj deleted file mode 100644 index 80b4ae78..00000000 --- a/extensions/geoip/msvc8/geoip.vcproj +++ /dev/null @@ -1,246 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/geoip/msvc9/geoip.sln b/extensions/geoip/msvc9/geoip.sln deleted file mode 100644 index eddcb1c5..00000000 --- a/extensions/geoip/msvc9/geoip.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geoip", "geoip.vcproj", "{698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Debug|Win32.ActiveCfg = Debug|Win32 - {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Debug|Win32.Build.0 = Debug|Win32 - {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Release|Win32.ActiveCfg = Release|Win32 - {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/geoip/msvc9/geoip.vcproj b/extensions/geoip/msvc9/geoip.vcproj deleted file mode 100644 index 8f1a7a4e..00000000 --- a/extensions/geoip/msvc9/geoip.vcproj +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/mysql/Makefile b/extensions/mysql/Makefile deleted file mode 100644 index 50e236e1..00000000 --- a/extensions/mysql/Makefile +++ /dev/null @@ -1,162 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -SRCDS_BASE = ~/srcds -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -MMSOURCE17 = ../../../mmsource-1.7 -MYSQL = ../../../mysql-5.0 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = dbi.mysql - -#Uncomment for Metamod: Source enabled extension -#USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp extension.cpp \ - mysql/MyBasicResults.cpp mysql/MyDatabase.cpp \ - mysql/MyBoundResults.cpp mysql/MyDriver.cpp \ - mysql/MyStatement.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - SRCDS = $(SRCDS_BASE) - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=4 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=5 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d - override ENGSET = true -endif - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(MMSOURCE17)/core/sourcehook \ - -I$(MYSQL)/include - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -endif - -LINK += $(MYSQL)/lib/libmysqlclient_r.a -lz -lpthread - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ - -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.so -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - mkdir -p $(BIN_DIR)/mysql - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \ - ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/mysql/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/mysql/msvc8/sm_mysql.sln b/extensions/mysql/msvc8/sm_mysql.sln deleted file mode 100644 index 25736ce5..00000000 --- a/extensions/mysql/msvc8/sm_mysql.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sm_mysql", "sm_mysql.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/mysql/msvc8/sm_mysql.vcproj b/extensions/mysql/msvc8/sm_mysql.vcproj deleted file mode 100644 index ab9a7c9a..00000000 --- a/extensions/mysql/msvc8/sm_mysql.vcproj +++ /dev/null @@ -1,293 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/mysql/msvc9/sm_mysql.sln b/extensions/mysql/msvc9/sm_mysql.sln deleted file mode 100644 index 427584b4..00000000 --- a/extensions/mysql/msvc9/sm_mysql.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sm_mysql", "sm_mysql.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/mysql/msvc9/sm_mysql.vcproj b/extensions/mysql/msvc9/sm_mysql.vcproj deleted file mode 100644 index 0aca646d..00000000 --- a/extensions/mysql/msvc9/sm_mysql.vcproj +++ /dev/null @@ -1,294 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/mysql/mysql/MyDriver.cpp b/extensions/mysql/mysql/MyDriver.cpp index c6941821..9221c6ff 100644 --- a/extensions/mysql/mysql/MyDriver.cpp +++ b/extensions/mysql/mysql/MyDriver.cpp @@ -96,11 +96,16 @@ MYSQL *Connect(const DatabaseInfo *info, char *error, size_t maxlength) MYSQL *mysql = mysql_init(NULL); const char *host = NULL, *socket = NULL; + decltype(info->maxTimeout) timeout = 60; if (info->maxTimeout > 0) { - mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&(info->maxTimeout)); + timeout = info->maxTimeout; } + mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&timeout); + mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (const char *)&timeout); + mysql_options(mysql, MYSQL_OPT_WRITE_TIMEOUT, (const char *)&timeout); + /* Have MySQL automatically reconnect if it times out or loses connection. * This will prevent "MySQL server has gone away" errors after a while. */ diff --git a/extensions/regex/Makefile b/extensions/regex/Makefile deleted file mode 100644 index 49dcb07e..00000000 --- a/extensions/regex/Makefile +++ /dev/null @@ -1,155 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -SRCDS_BASE = ~/srcds -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -MMSOURCE17 = ../../../mmsource-1.7 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = regex - -#Uncomment for Metamod: Source enabled extension -#USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp extension.cpp CRegEx.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - SRCDS = $(SRCDS_BASE) - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=4 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=5 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d - override ENGSET = true -endif - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(MMSOURCE17)/core/sourcehook -endif - -LINK += -m32 -ldl -lm - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -mfpmath=sse \ - -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += lib_darwin_x86/libpcre.a -dynamiclib - BINARY = $(PROJECT).ext.dylib -else - LINK += lib_linux/libpcre.a -static-libgcc -shared - BINARY = $(PROJECT).ext.so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \ - ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/regex/msvc10/regex.sln b/extensions/regex/msvc10/regex.sln deleted file mode 100644 index 48dbea6b..00000000 --- a/extensions/regex/msvc10/regex.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "regex", "regex.vcxproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/regex/msvc10/regex.vcxproj b/extensions/regex/msvc10/regex.vcxproj deleted file mode 100644 index c6b400d8..00000000 --- a/extensions/regex/msvc10/regex.vcxproj +++ /dev/null @@ -1,139 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6} - regex - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - regex.ext - - - regex.ext - - - - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;$(MMSOURCE17)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - ../lib_win/pcre.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - %(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions\" - - - - - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;$(MMSOURCE17)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - ../lib_win/pcre.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - %(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions\" - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/regex/msvc8/regex.sln b/extensions/regex/msvc8/regex.sln deleted file mode 100644 index 1126def0..00000000 --- a/extensions/regex/msvc8/regex.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "regex", "regex.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/regex/msvc8/regex.vcproj b/extensions/regex/msvc8/regex.vcproj deleted file mode 100644 index bce15d50..00000000 --- a/extensions/regex/msvc8/regex.vcproj +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/regex/msvc9/regex.sln b/extensions/regex/msvc9/regex.sln deleted file mode 100644 index 9df46af9..00000000 --- a/extensions/regex/msvc9/regex.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "regex", "regex.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/regex/msvc9/regex.vcproj b/extensions/regex/msvc9/regex.vcproj deleted file mode 100644 index e8a83362..00000000 --- a/extensions/regex/msvc9/regex.vcproj +++ /dev/null @@ -1,248 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/sdkhooks/Makefile b/extensions/sdkhooks/Makefile deleted file mode 100644 index 452026c8..00000000 --- a/extensions/sdkhooks/Makefile +++ /dev/null @@ -1,198 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_CSS = ../../../hl2sdk-css -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -HL2SDK_L4D2 = ../../../hl2sdk-l4d2 -HL2SDK_CSGO = ../../../hl2sdk-csgo -MMSOURCE19 = ../../../mmsource-central - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = sdkhooks - -#Uncomment for Metamod: Source enabled extension -USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp takedamageinfohack.cpp util.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE19)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls -I$(HL2SDK)/game_shared - GAMEFIX = 1.ep1 - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.ep2 - override ENGSET = true -endif -ifeq "$(ENGINE)" "css" - HL2SDK = $(HL2SDK_CSS) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=6 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.css - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=7 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.ep2v - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=8 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.l4d - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead2" - HL2SDK = $(HL2SDK_L4D2) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=9 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.l4d2 - override ENGSET = true -endif -ifeq "$(ENGINE)" "csgo" - HL2SDK = $(HL2SDK_CSGO) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=12 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.csgo - override ENGSET = true -endif - -ifeq ($(ENGINE),$(filter $(ENGINE), csgo left4dead2 orangeboxvalve css)) - LINK_HL2 = $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a libvstdlib.so libtier0.so -else - LINK_HL2 = $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a vstdlib_i486.so tier0_i486.so -endif - -ifeq "$(ENGINE)" "csgo" - LINK_HL2 += $(HL2LIB)/interfaces_i486.a -endif - -LINK += $(LINK_HL2) - -INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/tier0 \ - -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/extensions \ - -I$(SMSDK)/public/sourcepawn - -CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_BLOODYGOODTIME=4 -DSE_EYE=5 \ - -DSE_CSS=6 -DSE_ORANGEBOXVALVE=7 -DSE_LEFT4DEAD=8 -DSE_LEFT4DEAD2=9 -DSE_ALIENSWARM=10 - -DSE_PORTAL2=11 -DSE_CSGO=12 - -LINK += -m32 -ldl -lm - -CFLAGS += -D_LINUX -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC \ - -Wno-switch -Wall -Werror -Wno-uninitialized -Wno-invalid-offsetof -Wno-unused -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti -fno-threadsafe-statics - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.$(GAMEFIX).dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.$(GAMEFIX).so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk -ifeq ($(ENGINE),$(filter $(ENGINE), csgo left4dead2 orangeboxvalve css)) - ln -sf $(HL2LIB)/libvstdlib.so libvstdlib.so; - ln -sf $(HL2LIB)/libtier0.so libtier0.so; -else - ln -sf $(HL2LIB)/vstdlib_i486.so vstdlib_i486.so; - ln -sf $(HL2LIB)/tier0_i486.so tier0_i486.so; -endif - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/sdkhooks/extension.cpp b/extensions/sdkhooks/extension.cpp index 1cfd27ab..d0a0261d 100644 --- a/extensions/sdkhooks/extension.cpp +++ b/extensions/sdkhooks/extension.cpp @@ -184,7 +184,8 @@ SH_DECL_MANUALHOOK0_void(Spawn, 0, 0, 0); SH_DECL_MANUALHOOK1_void(StartTouch, 0, 0, 0, CBaseEntity *); SH_DECL_MANUALHOOK0_void(Think, 0, 0, 0); SH_DECL_MANUALHOOK1_void(Touch, 0, 0, 0, CBaseEntity *); -#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 +#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 SH_DECL_MANUALHOOK4_void(TraceAttack, 0, 0, 0, CTakeDamageInfoHack &, const Vector &, CGameTrace *, CDmgAccumulator *); #else SH_DECL_MANUALHOOK3_void(TraceAttack, 0, 0, 0, CTakeDamageInfoHack &, const Vector &, CGameTrace *); @@ -894,9 +895,6 @@ bool SDKHooks::Hook_LevelInit(char const *pMapName, char const *pMapEntities, ch g_pOnLevelInit->PushStringEx(g_szMapEntities, sizeof(g_szMapEntities), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); g_pOnLevelInit->Execute(&result); - if(result >= Pl_Handled) - RETURN_META_VALUE(MRES_SUPERCEDE, false); - if(result == Pl_Changed) RETURN_META_VALUE_NEWPARAMS(MRES_HANDLED, true, &IServerGameDLL::LevelInit, (pMapName, g_szMapEntities, pOldLevel, pLandmarkName, loadGame, background)); @@ -1394,7 +1392,8 @@ void SDKHooks::Hook_TouchPost(CBaseEntity *pOther) RETURN_META(MRES_IGNORED); } -#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 +#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator) #else void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr) @@ -1474,7 +1473,8 @@ void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, RETURN_META(MRES_IGNORED); } -#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 +#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator) #else void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr) diff --git a/extensions/sdkhooks/extension.h b/extensions/sdkhooks/extension.h index f1e1b297..e07bd5c3 100644 --- a/extensions/sdkhooks/extension.h +++ b/extensions/sdkhooks/extension.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include @@ -142,6 +142,9 @@ public: class IEntityListener { public: +#if SOURCE_ENGINE == SE_BMS + virtual void OnEntityPreSpawned( CBaseEntity *pEntity ) {}; +#endif virtual void OnEntityCreated( CBaseEntity *pEntity ) {}; virtual void OnEntitySpawned( CBaseEntity *pEntity ) {}; virtual void OnEntityDeleted( CBaseEntity *pEntity ) {}; @@ -313,7 +316,8 @@ public: void Hook_ThinkPost(); void Hook_Touch(CBaseEntity *pOther); void Hook_TouchPost(CBaseEntity *pOther); -#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 +#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 void Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator); void Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator); #else diff --git a/extensions/sdkhooks/msvc10/sdkhooks.sln b/extensions/sdkhooks/msvc10/sdkhooks.sln deleted file mode 100644 index 97e4a8f4..00000000 --- a/extensions/sdkhooks/msvc10/sdkhooks.sln +++ /dev/null @@ -1,74 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdktools", "sdktools.vcxproj", "{7A740927-C751-4312-BF9D-6367F8C508F8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - Bloody Good Time|Win32 = Debug - Bloody Good Time|Win32 - Debug - CS GO|Win32 = Debug - CS GO|Win32 - Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 - Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Debug - Swarm|Win32 = Debug - Swarm|Win32 - Release - Bloody Good Time|Win32 = Release - Bloody Good Time|Win32 - Release - CS GO|Win32 = Release - CS GO|Win32 - Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 - Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - Release - Swarm|Win32 = Release - Swarm|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Bloody Good Time|Win32.Build.0 = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Swarm|Win32.ActiveCfg = Debug - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Swarm|Win32.Build.0 = Debug - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Bloody Good Time|Win32.ActiveCfg = Release - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Bloody Good Time|Win32.Build.0 = Release - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Swarm|Win32.ActiveCfg = Release - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Swarm|Win32.Build.0 = Release - Swarm|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/sdkhooks/msvc10/sdkhooks.vcxproj.filters b/extensions/sdkhooks/msvc10/sdkhooks.vcxproj.filters deleted file mode 100644 index 45f3aa9f..00000000 --- a/extensions/sdkhooks/msvc10/sdkhooks.vcxproj.filters +++ /dev/null @@ -1,68 +0,0 @@ - - - - - {3FC90E55-360F-4370-ACE2-67D7691AFB97} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {046AC4F8-1F40-462f-B652-698F87CDCA5F} - h;hpp;hxx;hm;inl;inc;xsd - - - {4B7443F9-4DC9-4e59-BC1B-465800502EBC} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {223A2FA5-451B-4af5-9E85-162BF3598F7B} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - SourceMod SDK - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - SourceMod SDK - - - SourceMod SDK - - - Header Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/extensions/sdkhooks/takedamageinfohack.cpp b/extensions/sdkhooks/takedamageinfohack.cpp index 5e5a6300..ef71b46f 100644 --- a/extensions/sdkhooks/takedamageinfohack.cpp +++ b/extensions/sdkhooks/takedamageinfohack.cpp @@ -68,7 +68,8 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity * m_iDamageCustom = 0; #endif -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 m_iDamagedOtherPlayers = 0; m_iPlayerPenetrationCount = 0; m_flDamageBonus = 0.0f; diff --git a/extensions/sdktools/Makefile b/extensions/sdktools/Makefile deleted file mode 100644 index 200f8bc8..00000000 --- a/extensions/sdktools/Makefile +++ /dev/null @@ -1,206 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_CSS = ../../../hl2sdk-css -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -HL2SDK_L4D2 = ../../../hl2sdk-l4d2 -HL2SDK_CSGO = ../../../hl2sdk-csgo -MMSOURCE19 = ../../../mmsource-central - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = sdktools - -#Uncomment for Metamod: Source enabled extension -USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp extension.cpp vdecoder.cpp vcallbuilder.cpp vcaller.cpp \ - vnatives.cpp vsound.cpp tenatives.cpp trnatives.cpp tempents.cpp vstringtable.cpp \ - vhelpers.cpp vglobals.cpp voice.cpp inputnatives.cpp teamnatives.cpp output.cpp \ - outputnatives.cpp hooks.cpp gamerulesnatives.cpp CDetour/detours.cpp asm/asm.c \ - clientnatives.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE19)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls -I$(HL2SDK)/game_shared - GAMEFIX = 1.ep1 - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.ep2 - override ENGSET = true -endif -ifeq "$(ENGINE)" "css" - HL2SDK = $(HL2SDK_CSS) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=6 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.css - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=7 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.ep2v - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=8 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.l4d - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead2" - HL2SDK = $(HL2SDK_L4D2) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=9 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.l4d2 - override ENGSET = true -endif -ifeq "$(ENGINE)" "csgo" - HL2SDK = $(HL2SDK_CSGO) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=12 - METAMOD = $(MMSOURCE19)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework - GAMEFIX = 2.csgo - override ENGSET = true -endif - -ifeq ($(ENGINE),$(filter $(ENGINE), csgo left4dead2 orangeboxvalve css)) - LINK_HL2 = $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a libvstdlib.so libtier0.so -else - LINK_HL2 = $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a vstdlib_i486.so tier0_i486.so -endif - -ifeq "$(ENGINE)" "csgo" - LINK_HL2 += $(HL2LIB)/interfaces_i486.a -endif - -LINK += $(LINK_HL2) - -INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/tier0 \ - -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/extensions \ - -I$(SMSDK)/public/sourcepawn - -CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_BLOODYGOODTIME=4 -DSE_EYE=5 \ - -DSE_CSS=6 -DSE_ORANGEBOXVALVE=7 -DSE_LEFT4DEAD=8 -DSE_LEFT4DEAD2=9 -DSE_ALIENSWARM=10 - -DSE_PORTAL2=11 -DSE_CSGO=12 - -LINK += -m32 -ldl -lm - -CFLAGS += -D_LINUX -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC \ - -Wno-switch -Wall -Werror -Wno-uninitialized -Wno-invalid-offsetof -Wno-unused -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti -fno-threadsafe-statics - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.$(GAMEFIX).dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.$(GAMEFIX).so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - mkdir -p $(BIN_DIR)/CDetour - mkdir -p $(BIN_DIR)/asm -ifeq ($(ENGINE),$(filter $(ENGINE), csgo left4dead2 orangeboxvalve css)) - ln -sf $(HL2LIB)/libvstdlib.so libvstdlib.so; - ln -sf $(HL2LIB)/libtier0.so libtier0.so; -else - ln -sf $(HL2LIB)/vstdlib_i486.so vstdlib_i486.so; - ln -sf $(HL2LIB)/tier0_i486.so tier0_i486.so; -endif - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/CDetour/*.o - rm -rf $(BIN_DIR)/asm/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/sdktools/extension.cpp b/extensions/sdktools/extension.cpp index ae3f1f38..2b21b7ab 100644 --- a/extensions/sdktools/extension.cpp +++ b/extensions/sdktools/extension.cpp @@ -50,6 +50,9 @@ */ SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool); +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_CSGO +SH_DECL_HOOK1_void_vafmt(IVEngineServer, ClientCommand, SH_NOATTRIB, 0, edict_t *); +#endif SDKTools g_SdkTools; /**< Global singleton for extension's main interface */ IServerGameEnts *gameents = NULL; @@ -261,6 +264,10 @@ bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool #endif GET_V_IFACE_ANY(GetEngineFactory, soundemitterbase, ISoundEmitterSystemBase, SOUNDEMITTERSYSTEM_INTERFACE_VERSION); +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_CSGO + SH_ADD_HOOK(IVEngineServer, ClientCommand, engine, SH_MEMBER(this, &SDKTools::OnSendClientCommand), false); +#endif + gpGlobals = ismm->GetCGlobals(); enginePatch = SH_GET_CALLCLASS(engine); enginesoundPatch = SH_GET_CALLCLASS(engsound); @@ -268,6 +275,14 @@ bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool return true; } +bool SDKTools::SDK_OnMetamodUnload(char *error, size_t maxlen) +{ +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_CSGO + SH_REMOVE_HOOK(IVEngineServer, ClientCommand, engine, SH_MEMBER(this, &SDKTools::OnSendClientCommand), false); +#endif + return true; +} + void SDKTools::SDK_OnAllLoaded() { SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools); @@ -456,6 +471,22 @@ void SDKTools::OnClientPutInServer(int client) g_Hooks.OnClientPutInServer(client); } +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_CSGO +void SDKTools::OnSendClientCommand(edict_t *pPlayer, const char *szFormat) +{ + // Due to legacy code, CS:S and CS:GO still sends "name \"newname\"" to the + // client after aname change. The engine has a change hook on name causing + // it to reset to the player's Steam name. This quashes that to make + // SetClientName work properly. + if (!strncmp(szFormat, "name ", 5)) + { + RETURN_META(MRES_SUPERCEDE); + } + + RETURN_META(MRES_IGNORED); +} +#endif + class SDKTools_API : public ISDKTools { public: diff --git a/extensions/sdktools/extension.h b/extensions/sdktools/extension.h index 00144e4f..99c1b574 100644 --- a/extensions/sdktools/extension.h +++ b/extensions/sdktools/extension.h @@ -83,7 +83,7 @@ public: //public SDKExtension public: #if defined SMEXT_CONF_METAMOD virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late); - //virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen); + virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen); //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen); #endif public: //IConCommandBaseAccessor @@ -101,6 +101,9 @@ public: // IVoiceServer #else void OnClientCommand(edict_t *pEntity); #endif +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_CSGO + void OnSendClientCommand(edict_t *pPlayer, const char *szFormat); +#endif public: //ICommandTargetProcessor bool ProcessCommandTarget(cmd_target_info_t *info); diff --git a/extensions/sdktools/gamerulesnatives.cpp b/extensions/sdktools/gamerulesnatives.cpp index 98cd2a4a..3c4f6041 100644 --- a/extensions/sdktools/gamerulesnatives.cpp +++ b/extensions/sdktools/gamerulesnatives.cpp @@ -46,7 +46,7 @@ static CBaseEntity *FindEntityByNetClass(int start, const char *classname) for (int i = start; i < maxEntities; i++) { edict_t *current = gamehelpers->EdictOfIndex(i); - if (current == NULL) + if (current == NULL || current->IsFree()) continue; IServerNetworkable *network = current->GetNetworkable(); diff --git a/extensions/sdktools/hooks.h b/extensions/sdktools/hooks.h index 261e158d..28e1f286 100644 --- a/extensions/sdktools/hooks.h +++ b/extensions/sdktools/hooks.h @@ -35,7 +35,7 @@ class CUserCmd; #include "extension.h" -#include "amtl/am-vector.h" +#include #include "vtable_hook_helper.h" class CHookManager : IPluginsListener, IFeatureProvider diff --git a/extensions/sdktools/msvc10/sdktools.sln b/extensions/sdktools/msvc10/sdktools.sln deleted file mode 100644 index 97e4a8f4..00000000 --- a/extensions/sdktools/msvc10/sdktools.sln +++ /dev/null @@ -1,74 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdktools", "sdktools.vcxproj", "{7A740927-C751-4312-BF9D-6367F8C508F8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - Bloody Good Time|Win32 = Debug - Bloody Good Time|Win32 - Debug - CS GO|Win32 = Debug - CS GO|Win32 - Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 - Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Debug - Swarm|Win32 = Debug - Swarm|Win32 - Release - Bloody Good Time|Win32 = Release - Bloody Good Time|Win32 - Release - CS GO|Win32 = Release - CS GO|Win32 - Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 - Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - Release - Swarm|Win32 = Release - Swarm|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Bloody Good Time|Win32.Build.0 = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Swarm|Win32.ActiveCfg = Debug - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Swarm|Win32.Build.0 = Debug - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Bloody Good Time|Win32.ActiveCfg = Release - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Bloody Good Time|Win32.Build.0 = Release - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Swarm|Win32.ActiveCfg = Release - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Swarm|Win32.Build.0 = Release - Swarm|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/sdktools/msvc10/sdktools.vcxproj b/extensions/sdktools/msvc10/sdktools.vcxproj deleted file mode 100644 index db504c5b..00000000 --- a/extensions/sdktools/msvc10/sdktools.vcxproj +++ /dev/null @@ -1,1345 +0,0 @@ - - - - - Debug - Bloody Good Time - Win32 - - - Debug - CS GO - Win32 - - - Debug - CSS - Win32 - - - Debug - Dark Messiah - Win32 - - - Debug - Episode 1 - Win32 - - - Debug - EYE - Win32 - - - Debug - Left 4 Dead 2 - Win32 - - - Debug - Left 4 Dead - Win32 - - - Debug - Old Metamod - Win32 - - - Debug - Orange Box Valve - Win32 - - - Debug - Orange Box - Win32 - - - Debug - Swarm - Win32 - - - Release - Bloody Good Time - Win32 - - - Release - CS GO - Win32 - - - Release - CSS - Win32 - - - Release - Dark Messiah - Win32 - - - Release - Episode 1 - Win32 - - - Release - EYE - Win32 - - - Release - Left 4 Dead 2 - Win32 - - - Release - Left 4 Dead - Win32 - - - Release - Old Metamod - Win32 - - - Release - Orange Box Valve - Win32 - - - Release - Orange Box - Win32 - - - Release - Swarm - Win32 - - - - {7A740927-C751-4312-BF9D-6367F8C508F8} - sdk - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - true - true - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - false - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - sdktools.ext.2.ep2v - - - sdktools.ext.2.css - - - sdktools.ext.2.bgt - - - sdktools.ext.2.csgo - - - sdktools.ext.2.darkm - - - sdktools.ext.2.eye - - - sdktools.ext.2.ep1 - - - sdktools.ext.2.l4d - - - sdktools.ext.2.l4d2 - - - sdktools.ext.1.ep1 - - - sdktools.ext.2.ep2 - - - sdktools.ext.2.ep2v - - - sdktools.ext.2.css - - - sdktools.ext.2.swarm - - - sdktools.ext.2.bgt - - - sdktools.ext.2.csgo - - - sdktools.ext.2.darkm - - - sdktools.ext.2.eye - - - sdktools.ext.2.ep1 - - - sdktools.ext.2.l4d - - - sdktools.ext.2.l4d2 - - - sdktools.ext.1.ep1 - - - sdktools.ext.2.ep2 - - - sdktools.ext.2.swarm - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK)\game_shared;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK)\game_shared;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKOB)\game\shared;$(HL2SDKOB)\common;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\toolframework;$(HL2SDKOB)\public\mathlib;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;$(HL2SDKOB)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKOB)\game\shared;$(HL2SDKOB)\common;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\toolframework;$(HL2SDKOB)\public\mathlib;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;$(HL2SDKOB)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK)\game_shared;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - - - ..\..\..\public - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK)\game_shared;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKL4D)\game\shared;$(HL2SDKL4D)\common;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\toolframework;$(HL2SDKL4D)\public\mathlib;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;$(HL2SDKL4D)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKL4D)\game\shared;$(HL2SDKL4D)\common;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\toolframework;$(HL2SDKL4D)\public\mathlib;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;$(HL2SDKL4D)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-DARKM)\game_shared;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\mathlib;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;$(HL2SDK-DARKM)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-DARKM)\game_shared;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\mathlib;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;$(HL2SDK-DARKM)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKOBVALVE)\common;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\toolframework;$(HL2SDKOBVALVE)\public\mathlib;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(HL2SDKOBVALVE)\game\shared;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;$(HL2SDKOBVALVE)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKCSS)\common;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\toolframework;$(HL2SDKCSS)\public\mathlib;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(HL2SDKCSS)\game\shared;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;$(HL2SDKCSS)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Full - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKOBVALVE)\common;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\mathlib;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(HL2SDKOBVALVE)\game\shared;$(HL2SDKOBVALVE)\public\toolframework;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;$(HL2SDKOBVALVE)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Full - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKCSS)\common;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\mathlib;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(HL2SDKCSS)\game\shared;$(HL2SDKCSS)\public\toolframework;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;$(HL2SDKCSS)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-EYE)\common;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\toolframework;$(HL2SDK-EYE)\public\mathlib;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(HL2SDK-EYE)\game\shared;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=5;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;$(HL2SDK-EYE)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Full - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-EYE)\common;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\mathlib;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(HL2SDK-EYE)\game\shared;$(HL2SDK-EYE)\public\toolframework;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=5;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;$(HL2SDK-EYE)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKL4D2)\common;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\toolframework;$(HL2SDKL4D2)\public\mathlib;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\game\shared;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKL4D2)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKL4D2)\game\shared;$(HL2SDKL4D2)\common;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\toolframework;$(HL2SDKL4D2)\public\mathlib;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKL4D2)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-BGT)\game\shared;$(HL2SDK-BGT)\common;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\toolframework;$(HL2SDK-BGT)\public\mathlib;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=4;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;$(HL2SDK-BGT)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-BGT)\game\shared;$(HL2SDK-BGT)\common;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\toolframework;$(HL2SDK-BGT)\public\mathlib;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=4;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;$(HL2SDK-BGT)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-SWARM)\common;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\toolframework;$(HL2SDK-SWARM)\public\mathlib;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\game\shared;$(HL2SDK-SWARM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=10;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;$(HL2SDK-SWARM)\lib\public\mathlib.lib;$(HL2SDK-SWARM)\lib\public\interfaces.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-SWARM)\common;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\toolframework;$(HL2SDK-SWARM)\public\mathlib;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(HL2SDK-SWARM)\game\shared;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=10;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;$(HL2SDK-SWARM)\lib\public\mathlib.lib;$(HL2SDK-SWARM)\lib\public\interfaces.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKCSGO)\common;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\toolframework;$(HL2SDKCSGO)\public\mathlib;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\game\shared;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\mathlib.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKCSGO)\common;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\toolframework;$(HL2SDKCSGO)\public\mathlib;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(HL2SDKCSGO)\game\shared;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\mathlib.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/sdktools/msvc10/sdktools.vcxproj.filters b/extensions/sdktools/msvc10/sdktools.vcxproj.filters deleted file mode 100644 index b2224b9f..00000000 --- a/extensions/sdktools/msvc10/sdktools.vcxproj.filters +++ /dev/null @@ -1,149 +0,0 @@ - - - - - {3FC90E55-360F-4370-ACE2-67D7691AFB97} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {046AC4F8-1F40-462f-B652-698F87CDCA5F} - h;hpp;hxx;hm;inl;inc;xsd - - - {4B7443F9-4DC9-4e59-BC1B-465800502EBC} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {223A2FA5-451B-4af5-9E85-162BF3598F7B} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - SourceMod SDK - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - SourceMod SDK - - - SourceMod SDK - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/extensions/sdktools/msvc8/sdktools.sln b/extensions/sdktools/msvc8/sdktools.sln deleted file mode 100644 index 44ad9f59..00000000 --- a/extensions/sdktools/msvc8/sdktools.sln +++ /dev/null @@ -1,32 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdktools", "sdktools.vcproj", "{7A740927-C751-4312-BF9D-6367F8C508F8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/sdktools/msvc8/sdktools.vcproj b/extensions/sdktools/msvc8/sdktools.vcproj deleted file mode 100644 index a44e6e8a..00000000 --- a/extensions/sdktools/msvc8/sdktools.vcproj +++ /dev/null @@ -1,668 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/sdktools/msvc9/sdktools.sln b/extensions/sdktools/msvc9/sdktools.sln deleted file mode 100644 index 845beee7..00000000 --- a/extensions/sdktools/msvc9/sdktools.sln +++ /dev/null @@ -1,68 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdktools", "sdktools.vcproj", "{7A740927-C751-4312-BF9D-6367F8C508F8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - Bloody Good Time|Win32 = Debug - Bloody Good Time|Win32 - Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 - Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Debug - Swarm|Win32 = Debug - Swarm|Win32 - Release - Bloody Good Time|Win32 = Release - Bloody Good Time|Win32 - Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 - Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - Release - Swarm|Win32 = Release - Swarm|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Bloody Good Time|Win32.Build.0 = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Swarm|Win32.ActiveCfg = Debug - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Swarm|Win32.Build.0 = Debug - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Bloody Good Time|Win32.ActiveCfg = Release - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Bloody Good Time|Win32.Build.0 = Release - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Swarm|Win32.ActiveCfg = Release - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Swarm|Win32.Build.0 = Release - Swarm|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/sdktools/msvc9/sdktools.vcproj b/extensions/sdktools/msvc9/sdktools.vcproj deleted file mode 100644 index 5fe29f59..00000000 --- a/extensions/sdktools/msvc9/sdktools.vcproj +++ /dev/null @@ -1,1690 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/sdktools/teamnatives.cpp b/extensions/sdktools/teamnatives.cpp index d918d1ba..6334ca5e 100644 --- a/extensions/sdktools/teamnatives.cpp +++ b/extensions/sdktools/teamnatives.cpp @@ -219,6 +219,17 @@ static cell_t GetTeamClientCount(IPluginContext *pContext, const cell_t *params) return fn(g_Teams[teamindex].pEnt, 0); } +static cell_t GetTeamEntity(IPluginContext *pContext, const cell_t *params) +{ + int teamindex = params[1]; + if (teamindex >= (int)g_Teams.size() || !g_Teams[teamindex].ClassName) + { + return pContext->ThrowNativeError("Team index %d is invalid", teamindex); + } + + return gamehelpers->EntityToBCompatRef(g_Teams[teamindex].pEnt); +} + sp_nativeinfo_t g_TeamNatives[] = { {"GetTeamCount", GetTeamCount}, @@ -226,5 +237,6 @@ sp_nativeinfo_t g_TeamNatives[] = {"GetTeamScore", GetTeamScore}, {"SetTeamScore", SetTeamScore}, {"GetTeamClientCount", GetTeamClientCount}, + {"GetTeamEntity", GetTeamEntity}, {NULL, NULL} }; diff --git a/extensions/sdktools/tempents.cpp b/extensions/sdktools/tempents.cpp index 2a41b7b0..25eabb11 100644 --- a/extensions/sdktools/tempents.cpp +++ b/extensions/sdktools/tempents.cpp @@ -285,11 +285,12 @@ void TempEntityManager::Initialize() int offset; m_Loaded = false; -#if SOURCE_ENGINE == SE_TF2 \ - || SOURCE_ENGINE == SE_DODS \ - || SOURCE_ENGINE == SE_HL2DM \ - || SOURCE_ENGINE == SE_CSS \ - || SOURCE_ENGINE == SE_SDK2013 +#if SOURCE_ENGINE == SE_TF2 \ + || SOURCE_ENGINE == SE_DODS \ + || SOURCE_ENGINE == SE_HL2DM \ + || SOURCE_ENGINE == SE_CSS \ + || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS if (g_SMAPI->GetServerFactory(false)("VSERVERTOOLS003", nullptr)) { diff --git a/extensions/sdktools/vcaller.cpp b/extensions/sdktools/vcaller.cpp index ebcfe186..45d8e4bd 100644 --- a/extensions/sdktools/vcaller.cpp +++ b/extensions/sdktools/vcaller.cpp @@ -133,6 +133,7 @@ static cell_t PrepSDKCall_SetSignature(IPluginContext *pContext, const cell_t *p || SOURCE_ENGINE == SE_HL2DM \ || SOURCE_ENGINE == SE_DODS \ || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS \ || SOURCE_ENGINE == SE_TF2 \ || SOURCE_ENGINE == SE_LEFT4DEAD \ || SOURCE_ENGINE == SE_LEFT4DEAD2 \ diff --git a/extensions/sdktools/vdecoder.cpp b/extensions/sdktools/vdecoder.cpp index f4dc038d..8bac6555 100644 --- a/extensions/sdktools/vdecoder.cpp +++ b/extensions/sdktools/vdecoder.cpp @@ -290,8 +290,7 @@ DataStatus DecodeValveParam(IPluginContext *pContext, case Valve_Vector: { cell_t *addr; - int err; - err = pContext->LocalToPhysAddr(param, &addr); + pContext->LocalToPhysAddr(param, &addr); unsigned char *mem = (unsigned char *)buffer; if (data->type == PassType_Basic) @@ -317,12 +316,6 @@ DataStatus DecodeValveParam(IPluginContext *pContext, } } - if (err != SP_ERROR_NONE) - { - pContext->ThrowNativeErrorEx(err, "Could not read plugin data"); - return Data_Fail; - } - /* Use placement new to initialize the object cleanly * This has no destructor so we don't need to do * DestroyValveParam() or something :] diff --git a/extensions/sdktools/vglobals.cpp b/extensions/sdktools/vglobals.cpp index 1fa7a815..ded75ef4 100644 --- a/extensions/sdktools/vglobals.cpp +++ b/extensions/sdktools/vglobals.cpp @@ -211,13 +211,17 @@ bool UTIL_VerifySignature(const void *addr, const char *sig, size_t len) void GetIServer() { -#if SOURCE_ENGINE == SE_TF2 \ - || SOURCE_ENGINE == SE_DODS \ - || SOURCE_ENGINE == SE_HL2DM \ - || SOURCE_ENGINE == SE_CSS \ - || SOURCE_ENGINE == SE_SDK2013 +#if SOURCE_ENGINE == SE_TF2 \ + || SOURCE_ENGINE == SE_DODS \ + || SOURCE_ENGINE == SE_HL2DM \ + || SOURCE_ENGINE == SE_CSS \ + || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS \ + || SOURCE_ENGINE == SE_INSURGENCY +#if SOURCE_ENGINE != SE_INSURGENCY if (g_SMAPI->GetEngineFactory(false)("VEngineServer022", nullptr)) +#endif // !SE_INSURGENCY { iserver = engine->GetIServer(); return; diff --git a/extensions/sdktools/vhelpers.cpp b/extensions/sdktools/vhelpers.cpp index 9207dcba..d9e4b292 100644 --- a/extensions/sdktools/vhelpers.cpp +++ b/extensions/sdktools/vhelpers.cpp @@ -597,11 +597,12 @@ CEntityFactoryDictionary *GetEntityFactoryDictionary() { static CEntityFactoryDictionary *dict = NULL; -#if SOURCE_ENGINE == SE_TF2 \ - || SOURCE_ENGINE == SE_CSS \ - || SOURCE_ENGINE == SE_DODS \ - || SOURCE_ENGINE == SE_HL2DM \ +#if SOURCE_ENGINE == SE_TF2 \ + || SOURCE_ENGINE == SE_CSS \ + || SOURCE_ENGINE == SE_DODS \ + || SOURCE_ENGINE == SE_HL2DM \ || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS \ || SOURCE_ENGINE == SE_NUCLEARDAWN dict = (CEntityFactoryDictionary *) servertools->GetEntityFactoryDictionary(); #else diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index 3539ccb6..fab25181 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -2,7 +2,7 @@ * vim: set ts=4 : * ============================================================================= * SourceMod SDKTools Extension -* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -598,7 +598,8 @@ static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params) CellRecipientFilter rf; rf.SetToReliable(true); rf.Initialize(player_list, total_players); -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 engsound->EmitSound(rf, params[1], CHAN_AUTO, sound_name, VOL_NORM, ATTN_NORM, 0, PITCH_NORM, 0, &pos); #elif SOURCE_ENGINE < SE_PORTAL2 engsound->EmitSound(rf, params[1], CHAN_AUTO, sound_name, VOL_NORM, ATTN_NORM, 0, PITCH_NORM, &pos); @@ -797,6 +798,7 @@ static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *para || SOURCE_ENGINE == SE_DODS \ || SOURCE_ENGINE == SE_HL2DM \ || SOURCE_ENGINE == SE_CSS \ + || SOURCE_ENGINE == SE_BMS \ || SOURCE_ENGINE == SE_SDK2013 static bool bHasServerTools3 = !!g_SMAPI->GetServerFactory(false)("VSERVERTOOLS003", nullptr); @@ -1267,6 +1269,61 @@ static cell_t ActivateEntity(IPluginContext *pContext, const cell_t *params) return 1; } +static cell_t SetClientName(IPluginContext *pContext, const cell_t *params) +{ + if (iserver == NULL) + { + return pContext->ThrowNativeError("IServer interface not supported, file a bug report."); + } + + IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]); + IClient *pClient = iserver->GetClient(params[1] - 1); + + if (player == NULL || pClient == NULL) + { + return pContext->ThrowNativeError("Invalid client index %d", params[1]); + } + if (!player->IsConnected()) + { + return pContext->ThrowNativeError("Client %d is not connected", params[1]); + } + + static ValveCall *pCall = NULL; + if (!pCall) + { + ValvePassInfo params[1]; + InitPass(params[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL); + + if (!CreateBaseCall("SetClientName", ValveCall_Entity, NULL, params, 1, &pCall)) + { + return pContext->ThrowNativeError("\"SetClientName\" not supported by this mod"); + } + else if (!pCall) + { + return pContext->ThrowNativeError("\"SetClientName\" wrapper failed to initialize"); + } + } + + // The IClient vtable is +4 from the CBaseClient vtable due to multiple inheritance. + void *pGameClient = (void *)((intptr_t)pClient - 4); + + // Change the name in the engine. + START_CALL(); + void **ebuf = (void **)vptr; + *ebuf = pGameClient; + DECODE_VALVE_PARAM(2, vparams, 0); + FINISH_CALL_SIMPLE(NULL); + + // Notify the server of the change. +#if SOURCE_ENGINE == SE_DOTA + serverClients->ClientSettingsChanged(player->GetIndex()); +#else + serverClients->ClientSettingsChanged(player->GetEdict()); +#endif + + return 1; +} + static cell_t SetClientInfo(IPluginContext *pContext, const cell_t *params) { if (iserver == NULL) @@ -1418,6 +1475,7 @@ sp_nativeinfo_t g_Natives[] = {"EquipPlayerWeapon", WeaponEquip}, {"ActivateEntity", ActivateEntity}, {"SetClientInfo", SetClientInfo}, + {"SetClientName", SetClientName}, {"GetPlayerResourceEntity", GetPlayerResourceEntity}, {"GivePlayerAmmo", GivePlayerAmmo}, {NULL, NULL}, diff --git a/extensions/sdktools/vsound.cpp b/extensions/sdktools/vsound.cpp index a015c385..cfd4ec6a 100644 --- a/extensions/sdktools/vsound.cpp +++ b/extensions/sdktools/vsound.cpp @@ -41,7 +41,8 @@ SH_DECL_HOOK8_void(IVEngineServer, EmitAmbientSound, SH_NOATTRIB, 0, int, const #if SOURCE_ENGINE >= SE_PORTAL2 SH_DECL_HOOK17(IEngineSound, EmitSound, SH_NOATTRIB, 0, int, IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, float, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int); SH_DECL_HOOK17(IEngineSound, EmitSound, SH_NOATTRIB, 1, int, IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, soundlevel_t, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int); -#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 SH_DECL_HOOK15_void(IEngineSound, EmitSound, SH_NOATTRIB, 0, IRecipientFilter &, int, int, const char *, float, float, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int); SH_DECL_HOOK15_void(IEngineSound, EmitSound, SH_NOATTRIB, 1, IRecipientFilter &, int, int, const char *, float, soundlevel_t, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int); #else @@ -283,12 +284,64 @@ void SoundHooks::OnEmitAmbientSound(int entindex, const Vector &pos, const char } } +#if SOURCE_ENGINE >= SE_PORTAL2 +// This should probably be moved to the gamedata +#define SOUND_ENTRY_HASH_SEED 0x444F5441 + +uint32 GenerateSoundEntryHash(char const *pSoundEntry) +{ + // First we need to convert the sound entry to lowercase before we calculate the hash + int nSoundEntryLength = strlen(pSoundEntry); + char *pSoundEntryLowerCase = (char *)stackalloc(nSoundEntryLength + 1); + + for (int nIndex = 0; nIndex < nSoundEntryLength; nIndex++) + pSoundEntryLowerCase[nIndex] = tolower(pSoundEntry[nIndex]); + + // Second we need to calculate the hash using the algorithm reconstructed from CS:GO + const uint32 nMagicNumber = 0x5bd1e995; + + uint32 nSoundHash = SOUND_ENTRY_HASH_SEED ^ nSoundEntryLength; + + unsigned char *pData = (unsigned char *)pSoundEntryLowerCase; + + while (nSoundEntryLength >= 4) + { + uint32 nLittleDWord = LittleDWord(*(uint32 *)pData); + + nLittleDWord *= nMagicNumber; + nLittleDWord ^= nLittleDWord >> 24; + nLittleDWord *= nMagicNumber; + + nSoundHash *= nMagicNumber; + nSoundHash ^= nLittleDWord; + + pData += 4; + nSoundEntryLength -= 4; + } + + switch (nSoundEntryLength) + { + case 3: nSoundHash ^= pData[2] << 16; + case 2: nSoundHash ^= pData[1] << 8; + case 1: nSoundHash ^= pData[0]; + nSoundHash *= nMagicNumber; + }; + + nSoundHash ^= nSoundHash >> 13; + nSoundHash *= nMagicNumber; + nSoundHash ^= nSoundHash >> 15; + + return nSoundHash; +} +#endif + #if SOURCE_ENGINE >= SE_PORTAL2 int SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSoundEntry, unsigned int nSoundEntryHash, const char *pSample, float flVolume, soundlevel_t iSoundlevel, int nSeed, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity) -#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSample, float flVolume, soundlevel_t iSoundlevel, int iFlags, int iPitch, int iSpecialDSP, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, @@ -306,6 +359,15 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann char buffer[PLATFORM_MAX_PATH]; strcpy(buffer, pSample); + char soundEntry[PLATFORM_MAX_PATH] = ""; +#if SOURCE_ENGINE >= SE_PORTAL2 + Q_strncpy(soundEntry, pSoundEntry, sizeof(soundEntry)); +#endif + +#if SOURCE_ENGINE < SE_PORTAL2 + int nSeed = 0; +#endif + for (iter=m_NormalFuncs.begin(); iter!=m_NormalFuncs.end(); iter++) { int players[SM_MAXPLAYERS], size; @@ -321,6 +383,8 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann pFunc->PushCellByRef(reinterpret_cast(&iSoundlevel)); pFunc->PushCellByRef(&iPitch); pFunc->PushCellByRef(&iFlags); + pFunc->PushStringEx(soundEntry, sizeof(soundEntry), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); + pFunc->PushCellByRef(&nSeed); g_InSoundHook = true; pFunc->Execute(&res); g_InSoundHook = false; @@ -360,6 +424,16 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann #endif } +#if SOURCE_ENGINE >= SE_PORTAL2 + if (strcmp(pSoundEntry, soundEntry) != 0 || strcmp(pSample, buffer) != 0) + { + if (strcmp(soundEntry, buffer) == 0) + nSoundEntryHash = -1; + else if (strcmp(soundEntry, "") != 0) + nSoundEntryHash = GenerateSoundEntryHash(soundEntry); + } +#endif + CellRecipientFilter crf; crf.Initialize(players, size); #if SOURCE_ENGINE >= SE_PORTAL2 @@ -368,10 +442,11 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann -1, static_cast *, bool, float, int)>(&IEngineSound::EmitSound), - (crf, iEntIndex, iChannel, buffer, -1, buffer, flVolume, iSoundlevel, nSeed, iFlags, iPitch, pOrigin, + (crf, iEntIndex, iChannel, soundEntry, nSoundEntryHash, buffer, flVolume, iSoundlevel, nSeed, iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity) ); -#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 RETURN_META_NEWPARAMS( MRES_IGNORED, static_cast *pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity) -#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSample, float flVolume, float flAttenuation, int iFlags, int iPitch, int iSpecialDSP, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, @@ -421,6 +497,15 @@ void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChan char buffer[PLATFORM_MAX_PATH]; strcpy(buffer, pSample); + char soundEntry[PLATFORM_MAX_PATH] = ""; +#if SOURCE_ENGINE >= SE_PORTAL2 + Q_strncpy(soundEntry, pSoundEntry, sizeof(soundEntry)); +#endif + +#if SOURCE_ENGINE < SE_PORTAL2 + int nSeed = 0; +#endif + for (iter=m_NormalFuncs.begin(); iter!=m_NormalFuncs.end(); iter++) { int players[SM_MAXPLAYERS], size; @@ -436,6 +521,8 @@ void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChan pFunc->PushCellByRef(&sndlevel); pFunc->PushCellByRef(&iPitch); pFunc->PushCellByRef(&iFlags); + pFunc->PushStringEx(soundEntry, sizeof(soundEntry), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); + pFunc->PushCellByRef(&nSeed); g_InSoundHook = true; pFunc->Execute(&res); g_InSoundHook = false; @@ -475,6 +562,16 @@ void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChan #endif } +#if SOURCE_ENGINE >= SE_PORTAL2 + if (strcmp(pSoundEntry, soundEntry) != 0 || strcmp(pSample, buffer) != 0) + { + if (strcmp(soundEntry, buffer) == 0) + nSoundEntryHash = -1; + else if (strcmp(soundEntry, "") != 0) + nSoundEntryHash = GenerateSoundEntryHash(soundEntry); + } +#endif + CellRecipientFilter crf; crf.Initialize(players, size); #if SOURCE_ENGINE >= SE_PORTAL2 @@ -483,10 +580,11 @@ void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChan -1, static_cast *, bool, float, int)>(&IEngineSound::EmitSound), - (crf, iEntIndex, iChannel, buffer, -1, buffer, flVolume, SNDLVL_TO_ATTN(static_cast(sndlevel)), + (crf, iEntIndex, iChannel, soundEntry, nSoundEntryHash, buffer, flVolume, SNDLVL_TO_ATTN(static_cast(sndlevel)), nSeed, iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity) ); -#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 RETURN_META_NEWPARAMS( MRES_IGNORED, static_castThrowNativeError("EmitSoundEntry is not available in this game."); +#else + cell_t *addr, *cl_array; + CellRecipientFilter crf; + unsigned int numClients; + int client; + IGamePlayer *pPlayer = NULL; + + pContext->LocalToPhysAddr(params[1], &cl_array); + numClients = params[2]; + + /* Client validation */ + for (unsigned int i = 0; i < numClients; i++) + { + client = cl_array[i]; + pPlayer = playerhelpers->GetGamePlayer(client); + + if (!pPlayer) + { + return pContext->ThrowNativeError("Client index %d is invalid", client); + } + else if (!pPlayer->IsInGame()) { + return pContext->ThrowNativeError("Client %d is not connected", client); + } + } + + crf.Initialize(cl_array, numClients); + + char *soundEntry; + pContext->LocalToString(params[3], &soundEntry); + + char *sample; + pContext->LocalToString(params[4], &sample); + + // By default, we want the hash to equal maxint + unsigned int soundEntryHash = -1; + + // We only generate a hash if the sample is not the same as the sound entry and the sound entry is not empty. + if (strcmp(soundEntry, sample) != 0 && strcmp(soundEntry, "") != 0) + soundEntryHash = GenerateSoundEntryHash(soundEntry); + + int entity = SoundReferenceToIndex(params[5]); + int channel = params[6]; + int level = params[7]; + int seed = params[8]; + int flags = params[9]; + float vol = sp_ctof(params[10]); + int pitch = params[11]; + int speakerentity = params[12]; + + Vector *pOrigin = NULL, origin; + Vector *pDir = NULL, dir; + + pContext->LocalToPhysAddr(params[13], &addr); + if (addr != pContext->GetNullRef(SP_NULL_VECTOR)) + { + pOrigin = &origin; + origin.x = sp_ctof(addr[0]); + origin.y = sp_ctof(addr[1]); + origin.z = sp_ctof(addr[2]); + } + + pContext->LocalToPhysAddr(params[14], &addr); + if (addr != pContext->GetNullRef(SP_NULL_VECTOR)) + { + pDir = &dir; + dir.x = sp_ctof(addr[0]); + dir.y = sp_ctof(addr[1]); + dir.z = sp_ctof(addr[2]); + } + + bool updatePos = params[15] ? true : false; + float soundtime = sp_ctof(params[16]); + + CUtlVector *pOrigVec = NULL; + CUtlVector origvec; + if (params[0] > 16) + { + pOrigVec = &origvec; + for (cell_t i = 17; i <= params[0]; i++) + { + Vector vec; + pContext->LocalToPhysAddr(params[i], &addr); + vec.x = sp_ctof(addr[0]); + vec.y = sp_ctof(addr[1]); + vec.z = sp_ctof(addr[2]); + origvec.AddToTail(vec); + } + } + + /* If we're going to a "local player" and this is a dedicated server, + * intelligently redirect each sound. + */ + + if (entity == -2 && engine->IsDedicatedServer()) + { + for (unsigned int i = 0; i < numClients; i++) + { + cell_t player[1]; + player[0] = cl_array[i]; + crf.Reset(); + crf.Initialize(player, 1); + + if (g_InSoundHook) + { + SH_CALL(enginesoundPatch, + static_cast *, bool, float, int)> + (&IEngineSound::EmitSound))(crf, player[0], channel, soundEntry, soundEntryHash, sample, vol, (soundlevel_t)level, seed, + flags, pitch, pOrigin, pDir, pOrigVec, updatePos, soundtime, speakerentity); + } + else + { + engsound->EmitSound(crf, player[0], channel, soundEntry, soundEntryHash, sample, vol, (soundlevel_t)level, seed, + flags, pitch, pOrigin, pDir, pOrigVec, updatePos, soundtime, speakerentity); + } + } + } + else { + if (g_InSoundHook) + { + SH_CALL(enginesoundPatch, + static_cast *, bool, float, int)> + (&IEngineSound::EmitSound))(crf, entity, channel, soundEntry, soundEntryHash, sample, vol, (soundlevel_t)level, + seed, flags, pitch, pOrigin, pDir, pOrigVec, updatePos, soundtime, speakerentity); + } + else + { + engsound->EmitSound(crf, entity, channel, soundEntry, soundEntryHash, sample, vol, (soundlevel_t)level, seed, + flags, pitch, pOrigin, pDir, pOrigVec, updatePos, soundtime, speakerentity); + } + } + + return 1; +#endif +} + static cell_t EmitSentence(IPluginContext *pContext, const cell_t *params) { cell_t *addr; @@ -1124,7 +1365,8 @@ static cell_t EmitSentence(IPluginContext *pContext, const cell_t *params) #endif flags, pitch, -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 0, #endif pOrigin, @@ -1253,6 +1495,7 @@ sp_nativeinfo_t g_SoundNatives[] = {"EmitAmbientSound", EmitAmbientSound}, {"EmitSentence", EmitSentence}, {"EmitSound", EmitSound}, + {"EmitSoundEntry", EmitSoundEntry}, {"FadeClientVolume", FadeClientVolume}, {"GetSoundDuration", GetSoundDuration}, {"PrefetchSound", PrefetchSound}, diff --git a/extensions/sdktools/vsound.h b/extensions/sdktools/vsound.h index 855d74cf..531e1fa5 100644 --- a/extensions/sdktools/vsound.h +++ b/extensions/sdktools/vsound.h @@ -67,7 +67,8 @@ public: const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity); #else -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \ + || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 void OnEmitSound(IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSample, float flVolume, soundlevel_t iSoundlevel, int iFlags, int iPitch, int iSpecialDSP, const Vector *pOrigin, @@ -86,7 +87,7 @@ public: float flAttenuation, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity); -#endif // SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 +#endif // SOURCE_ENGINE == SE_CSS, SE_HL2DM, SE_DODS, SE_SDK2013, SE_BMS, SE_TF2 #endif // SOURCE_ENGINE >= SE_PORTAL2 private: size_t _FillInPlayers(int *pl_array, IRecipientFilter *pFilter); diff --git a/extensions/sqlite/Makefile b/extensions/sqlite/Makefile deleted file mode 100644 index d68ab723..00000000 --- a/extensions/sqlite/Makefile +++ /dev/null @@ -1,169 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -SRCDS_BASE = ~/srcds -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -MMSOURCE17 = ../../../mmsource-1.7 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = dbi.sqlite - -#Uncomment for Metamod: Source enabled extension -#USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp sdk/sm_memtable.cpp extension.cpp \ - driver/SqDatabase.cpp driver/SqDriver.cpp driver/SqQuery.cpp \ - driver/SqResults.cpp - -OBJECTS += sqlite-source/sqlite3.c - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - SRCDS = $(SRCDS_BASE) - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=4 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=5 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d - override ENGSET = true -endif - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(MMSOURCE17)/core/sourcehook -endif - -LINK += -lpthread -m32 -ldl -lm -INCLUDE += -I$(SMSDK)/public/amtl - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \ - -Wno-uninitialized -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -DSQLITE_THREADSAFE \ - -DSQLITE_OMIT_LOAD_EXTENSION -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) -OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -$(BIN_DIR)/%.o: %.c - $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - mkdir -p $(BIN_DIR)/driver - mkdir -p $(BIN_DIR)/sqlite-source - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \ - ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/driver/*.o - rm -rf $(BIN_DIR)/sqlite-source/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/sqlite/msvc10/sm_sqlite.sln b/extensions/sqlite/msvc10/sm_sqlite.sln deleted file mode 100644 index 138592aa..00000000 --- a/extensions/sqlite/msvc10/sm_sqlite.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite", "sm_sqlite.vcxproj", "{B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/sqlite/msvc10/sm_sqlite.vcxproj b/extensions/sqlite/msvc10/sm_sqlite.vcxproj deleted file mode 100644 index 998509ef..00000000 --- a/extensions/sqlite/msvc10/sm_sqlite.vcxproj +++ /dev/null @@ -1,146 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE} - sm_sqlite - Win32Proj - sqlite - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - dbi.sqlite.ext - dbi.sqlite.ext - - - - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;THREADSAFE;SQLITE_OMIT_LOAD_EXTENSION;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public;%(AdditionalIncludeDirectories) - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SQLITE_THREADSAFE;SQLITE_OMIT_LOAD_EXTENSION;_WIN32_WINNT=0x0400;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public;%(AdditionalIncludeDirectories) - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - - - - Level2 - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/sqlite/msvc10/sm_sqlite.vcxproj.filters b/extensions/sqlite/msvc10/sm_sqlite.vcxproj.filters deleted file mode 100644 index 135c9f4e..00000000 --- a/extensions/sqlite/msvc10/sm_sqlite.vcxproj.filters +++ /dev/null @@ -1,101 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {31958233-BB2D-4e41-A8F9-CE8A4684F436} - - - {befce3ed-4516-4190-b88b-8e851fb08b7a} - - - {1c5893c1-d6df-4b97-8212-622e992d5426} - - - {bde390b0-58aa-4805-b8bb-06c15aca9bb4} - - - {aa3d4cd6-c36b-4c59-8761-55d13b414df0} - - - {41b5e441-03e2-4c1b-80b9-ebeb0caafbf3} - - - {3eddb954-2a2a-49d3-a27b-0a7f8c328ac6} - - - - - Source Files - - - SourceMod SDK - - - SourceMod SDK - - - SQLite Source\Source Files - - - Driver\Source Files - - - Driver\Source Files - - - Driver\Source Files - - - Driver\Source Files - - - - - Header Files - - - Resource Files - - - SourceMod SDK - - - SourceMod SDK - - - SourceMod SDK - - - SQLite Source\Header Files - - - Driver\Header Files - - - Driver\Header Files - - - Driver\Header Files - - - Driver\Header Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/extensions/sqlite/msvc8/sm_sqlite.sln b/extensions/sqlite/msvc8/sm_sqlite.sln deleted file mode 100644 index 1805b0c9..00000000 --- a/extensions/sqlite/msvc8/sm_sqlite.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sm_sqlite", "sm_sqlite.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/sqlite/msvc8/sm_sqlite.vcproj b/extensions/sqlite/msvc8/sm_sqlite.vcproj deleted file mode 100644 index f60094b8..00000000 --- a/extensions/sqlite/msvc8/sm_sqlite.vcproj +++ /dev/null @@ -1,893 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/sqlite/msvc9/sm_sqlite.sln b/extensions/sqlite/msvc9/sm_sqlite.sln deleted file mode 100644 index b06d97f9..00000000 --- a/extensions/sqlite/msvc9/sm_sqlite.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sm_sqlite", "sm_sqlite.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/sqlite/msvc9/sm_sqlite.vcproj b/extensions/sqlite/msvc9/sm_sqlite.vcproj deleted file mode 100644 index d9594626..00000000 --- a/extensions/sqlite/msvc9/sm_sqlite.vcproj +++ /dev/null @@ -1,320 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/tf2/Makefile b/extensions/tf2/Makefile deleted file mode 100644 index 58ef3049..00000000 --- a/extensions/tf2/Makefile +++ /dev/null @@ -1,162 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -SRCDS_BASE = ~/srcds -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -MMSOURCE17 = ../../../mmsource-1.9 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = game.tf2 - -#Uncomment for Metamod: Source enabled extension -USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp criticals.cpp \ - holiday.cpp gameplayrules.cpp conditions.cpp util.cpp teleporter.cpp CDetour/detours.cpp asm/asm.c - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - SRCDS = $(SRCDS_BASE) - GAMEFIX = 1.ep1 - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - GAMEFIX = 2.ep2 - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=4 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - GAMEFIX = 2.ep2v - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=5 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d - GAMEFIX = 2.l4d - override ENGSET = true -endif - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(HL2LIB)/tier1_i486.a libtier0_srv.so - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/extensions \ - -I$(SMSDK)/public/sourcepawn - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -endif - -LINK += -m32 -ldl -lm - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ - -Wno-array-bounds -Wno-unused -Wno-uninitialized -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.$(GAMEFIX).dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.$(GAMEFIX).so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - mkdir -p $(BIN_DIR)/CDetour - mkdir -p $(BIN_DIR)/asm - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(SRCDS)/bin/libtier0_srv.so libtier0_srv.so; \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/tf2/conditions.cpp b/extensions/tf2/conditions.cpp index ea8d7514..225df413 100644 --- a/extensions/tf2/conditions.cpp +++ b/extensions/tf2/conditions.cpp @@ -2,7 +2,7 @@ * vim: set ts=4 : * ============================================================================= * SourceMod Team Fortress 2 Extension - * Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -31,152 +31,135 @@ #include "extension.h" #include "conditions.h" -#include "util.h" - -#include - -#include - -const int TF_MAX_CONDITIONS = 128; - -typedef CBitVec condbitvec_t; -condbitvec_t g_PlayerActiveConds[SM_MAXPLAYERS + 1]; IForward *g_addCondForward = NULL; IForward *g_removeCondForward = NULL; -int playerCondOffset = -1; -int playerCondExOffset = -1; -int playerCondEx2Offset = -1; -int playerCondEx3Offset = -1; -int conditionBitsOffset = -1; - -bool g_bIgnoreRemove; - -#define MAX_CONDS (sizeof(uint64_t) * 8) - -inline void GetPlayerConds(CBaseEntity *pPlayer, condbitvec_t *pOut) +struct CondChangeData_t { - uint32_t tmp = *(uint32_t *)((intptr_t)pPlayer + playerCondOffset); - tmp |= *(uint32_t *)((intptr_t)pPlayer + conditionBitsOffset); - pOut->SetDWord(0, tmp); - tmp = *(uint32_t *)((intptr_t)pPlayer + playerCondExOffset); - pOut->SetDWord(1, tmp); - tmp = *(uint32_t *)((intptr_t)pPlayer + playerCondEx2Offset); - pOut->SetDWord(2, tmp); - tmp = *(uint32_t *)((intptr_t) pPlayer + playerCondEx3Offset); - pOut->SetDWord(3, tmp); + CBaseHandle hPlayer; + PlayerConditionsMgr::CondVar var; + int newConds; +}; + +static void HandleCondChange(void *pData) +{ + auto *pCondData = reinterpret_cast(pData); + g_CondMgr.ProcessCondChange(pCondData); + delete pCondData; } -inline void CondBitVecAndNot(const condbitvec_t &src, const condbitvec_t &addStr, condbitvec_t *out) +void PlayerConditionsMgr::ProcessCondChange(CondChangeData_t *pCondData) { - static_assert(TF_MAX_CONDITIONS == 128, "CondBitVecAndNot hack is hardcoded for 128-bit bitvec."); - - // CBitVec has And and Not, but not a simple, combined AndNot. - // We'll also treat the halves as two 64-bit ints instead of four 32-bit ints - // as a minor optimization (maybe?) that the compiler is not making itself. - uint64 *pDest = (uint64 *)out->Base(); - const uint64 *pOperand1 = (const uint64 *) src.Base(); - const uint64 *pOperand2 = (const uint64 *) addStr.Base(); - - pDest[0] = pOperand1[0] & ~pOperand2[0]; - pDest[1] = pOperand1[1] & ~pOperand2[1]; -} - -void Conditions_OnGameFrame(bool simulating) -{ - if (!simulating) + auto *pEdict = gamehelpers->GetHandleEntity(pCondData->hPlayer); + auto *pPlayer = playerhelpers->GetGamePlayer(pEdict); + if (!pPlayer || !pPlayer->IsInGame()) return; - static condbitvec_t newconds; - - static condbitvec_t addedconds; - static condbitvec_t removedconds; + int client = pCondData->hPlayer.GetEntryIndex(); + int newConds = 0; + int prevConds = 0; + CondVar var = pCondData->var; - int maxClients = gpGlobals->maxClients; - for (int i = 1; i <= maxClients; i++) + if (var == m_nPlayerCond) { - IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(i); - if (!pPlayer->IsInGame() || pPlayer->IsSourceTV() || pPlayer->IsReplay()) - continue; + prevConds = m_OldConds[client][_condition_bits] | m_OldConds[client][var]; + newConds = m_OldConds[client][_condition_bits] | pCondData->newConds; + } + else if (var == _condition_bits) + { + prevConds = m_OldConds[client][m_nPlayerCond] | m_OldConds[client][var]; + newConds = m_OldConds[client][m_nPlayerCond] | pCondData->newConds; + } + else + { + prevConds = m_OldConds[client][var]; + newConds = pCondData->newConds; + } - CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i); - condbitvec_t &oldconds = g_PlayerActiveConds[i]; - GetPlayerConds(pEntity, &newconds); + if (prevConds != newConds) + { + int changedConds = newConds ^ prevConds; + int addedConds = changedConds & newConds; + int removedConds = changedConds & prevConds; + m_OldConds[client][var] = newConds; - if (oldconds == newconds) - continue; - - CondBitVecAndNot(newconds, oldconds, &addedconds); - CondBitVecAndNot(oldconds, newconds, &removedconds); - - int bit; - bit = -1; - while ((bit = addedconds.FindNextSetBit(bit + 1)) != -1) + for (int i = 0; i < 32; i++) { - g_addCondForward->PushCell(i); - g_addCondForward->PushCell(bit); - g_addCondForward->Execute(NULL, NULL); + if (addedConds & (1 << i)) + { + g_addCondForward->PushCell(client); + g_addCondForward->PushCell(i + m_CondOffset[var]); + g_addCondForward->Execute(NULL); + } + else if (removedConds & (1 << i)) + { + g_removeCondForward->PushCell(client); + g_removeCondForward->PushCell(i + m_CondOffset[var]); + g_removeCondForward->Execute(NULL); + } } - - bit = -1; - while ((bit = removedconds.FindNextSetBit(bit + 1)) != -1) - { - g_removeCondForward->PushCell(i); - g_removeCondForward->PushCell(bit); - g_removeCondForward->Execute(NULL, NULL); - } - - g_PlayerActiveConds[i] = newconds; } } -bool InitialiseConditionChecks() +template +static void OnPlayerCondChange(const SendProp *pProp, const void *pStructBase, const void *pData, DVariant *pOut, int iElement, int objectID) { - sm_sendprop_info_t prop; - if (!gamehelpers->FindSendPropInfo("CTFPlayer", "m_nPlayerCond", &prop)) + g_CondMgr.OnConVarChange(CondVar, pProp, pStructBase, pData, pOut, iElement, objectID); +} + +void PlayerConditionsMgr::OnConVarChange(CondVar var, const SendProp *pProp, const void *pStructBase, const void *pData, DVariant *pOut, int iElement, int objectID) +{ + auto pCondData = new CondChangeData_t; + pCondData->hPlayer = ((IHandleEntity *)((intp)pData - GetPropOffs(var)))->GetRefEHandle(); + pCondData->var = var; + pCondData->newConds = *(int *)pData; + + g_pSM->AddFrameAction(&HandleCondChange, pCondData); + + if (m_BackupProxyFns[var] != nullptr) + m_BackupProxyFns[var](pProp, pStructBase, pData, pOut, iElement, objectID); +} + +template +bool PlayerConditionsMgr::SetupProp(const char *varname) +{ + if (!gamehelpers->FindSendPropInfo("CTFPlayer", varname, &m_CondVarProps[var])) { - g_pSM->LogError(myself, "Failed to find m_nPlayerCond prop offset"); - return false; - } - - playerCondOffset = prop.actual_offset; - - if (!gamehelpers->FindSendPropInfo("CTFPlayer", "_condition_bits", &prop)) - { - g_pSM->LogError(myself, "Failed to find _condition_bits prop offset"); + g_pSM->LogError(myself, "Failed to find %s prop offset", varname); return false; } - conditionBitsOffset = prop.actual_offset; + m_BackupProxyFns[var] = GetProp(var)->GetProxyFn(); + GetProp(var)->SetProxyFn(OnPlayerCondChange); - if (!gamehelpers->FindSendPropInfo("CTFPlayer", "m_nPlayerCondEx", &prop)) - { - g_pSM->LogError(myself, "Failed to find m_nPlayerCondEx prop offset"); + return true; +} + +PlayerConditionsMgr::PlayerConditionsMgr() +{ + m_CondOffset[m_nPlayerCond] = 0; + m_CondOffset[_condition_bits] = 0; + m_CondOffset[m_nPlayerCondEx] = 32; + m_CondOffset[m_nPlayerCondEx2] = 64; + m_CondOffset[m_nPlayerCondEx3] = 96; +} + +bool PlayerConditionsMgr::Init() +{ + memset(m_BackupProxyFns, 0, sizeof(m_BackupProxyFns)); + + bool bFoundProps = SetupProp("m_nPlayerCond") + && SetupProp<_condition_bits>("_condition_bits") + && SetupProp("m_nPlayerCondEx") + && SetupProp("m_nPlayerCondEx2") + && SetupProp("m_nPlayerCondEx3"); + + if (!bFoundProps) return false; - } - - playerCondExOffset = prop.actual_offset; - if (!gamehelpers->FindSendPropInfo("CTFPlayer", "m_nPlayerCondEx2", &prop)) - { - g_pSM->LogError(myself, "Failed to find m_nPlayerCondEx2 prop offset"); - return false; - } - - playerCondEx2Offset = prop.actual_offset; + playerhelpers->AddClientListener(this); - if (!gamehelpers->FindSendPropInfo("CTFPlayer", "m_nPlayerCondEx3", &prop)) - { - g_pSM->LogError(myself, "Failed to find m_nPlayerCondEx3 prop offset"); - return false; - } - - playerCondEx3Offset = prop.actual_offset; - - if (playerCondOffset == -1 || playerCondExOffset == -1 || conditionBitsOffset == -1 || playerCondEx2Offset == -1 || playerCondEx3Offset == -1) - return false; - int maxClients = gpGlobals->maxClients; for (int i = 1; i <= maxClients; i++) { @@ -184,21 +167,29 @@ bool InitialiseConditionChecks() if (!pPlayer || !pPlayer->IsInGame()) continue; - GetPlayerConds(gamehelpers->ReferenceToEntity(i), &g_PlayerActiveConds[i]); + CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i); + for (size_t j = 0; j < CondVar_Count; ++j) + { + m_OldConds[i][j] = *(int *)((intp) pEntity + GetPropOffs((CondVar)j)); + } } - g_pSM->AddGameFrameHook(Conditions_OnGameFrame); - return true; } -void Conditions_OnClientPutInServer(int client) +void PlayerConditionsMgr::Shutdown() { - g_PlayerActiveConds[client].ClearAll(); + for (size_t i = 0; i < CondVar_Count; ++i) + { + GetProp((CondVar)i)->SetProxyFn(m_BackupProxyFns[i]); + } + + playerhelpers->RemoveClientListener(this); } -void RemoveConditionChecks() +void PlayerConditionsMgr::OnClientPutInServer(int client) { - g_pSM->RemoveGameFrameHook(Conditions_OnGameFrame); + memset(&m_OldConds[client], 0, sizeof(m_OldConds[0])); } +PlayerConditionsMgr g_CondMgr; diff --git a/extensions/tf2/conditions.h b/extensions/tf2/conditions.h index f8bf08b2..4aa76091 100644 --- a/extensions/tf2/conditions.h +++ b/extensions/tf2/conditions.h @@ -2,7 +2,7 @@ * vim: set ts=4 : * ============================================================================= * SourceMod Team Fortress 2 Extension - * Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -33,15 +33,50 @@ #define _INCLUDE_SOURCEMOD_CONDITIONS_H_ #include "extension.h" -#include -#include -#include "CDetour/detours.h" -bool InitialiseConditionChecks(); -void RemoveConditionChecks(); -void DoRemoveCond(int client, int condition); +struct CondChangeData_t; -void Conditions_OnClientPutInServer(int client); +class PlayerConditionsMgr : public IClientListener +{ +public: + PlayerConditionsMgr(); + bool Init(); + void Shutdown(); +public: // IClientListener + void OnClientPutInServer(int client); +public: + enum CondVar : size_t + { + m_nPlayerCond, + _condition_bits, + m_nPlayerCondEx, + m_nPlayerCondEx2, + m_nPlayerCondEx3, + + CondVar_Count + }; + + void OnConVarChange(CondVar var, const SendProp *pProp, const void *pStructBase, const void *pData, DVariant *pOut, int iElement, int objectID); + void ProcessCondChange(CondChangeData_t *pCondData); +private: + inline unsigned int GetPropOffs(CondVar var) + { + return m_CondVarProps[var].actual_offset; + } + inline SendProp *GetProp(CondVar var) + { + return m_CondVarProps[var].prop; + } + template + bool SetupProp(const char *varname); +private: + int m_OldConds[SM_MAXPLAYERS + 1][CondVar_Count]; + sm_sendprop_info_t m_CondVarProps[CondVar_Count]; + int m_CondOffset[CondVar_Count]; + SendVarProxyFn m_BackupProxyFns[CondVar_Count]; +}; + +extern PlayerConditionsMgr g_CondMgr; extern IForward *g_addCondForward; extern IForward *g_removeCondForward; diff --git a/extensions/tf2/extension.cpp b/extensions/tf2/extension.cpp index 074611ad..71f5279f 100644 --- a/extensions/tf2/extension.cpp +++ b/extensions/tf2/extension.cpp @@ -2,7 +2,7 @@ * vim: set ts=4 : * ============================================================================= * SourceMod Team Fortress 2 Extension - * Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -116,7 +116,6 @@ bool TF2Tools::SDK_OnLoad(char *error, size_t maxlength, bool late) plsys->AddPluginsListener(this); playerhelpers->RegisterCommandTargetProcessor(this); - playerhelpers->AddClientListener(this); g_critForward = forwards->CreateForward("TF2_CalcIsAttackCritical", ET_Hook, 4, NULL, Param_Cell, Param_Cell, Param_String, Param_CellByRef); g_addCondForward = forwards->CreateForward("TF2_OnConditionAdded", ET_Ignore, 2, NULL, Param_Cell, Param_Cell); @@ -172,7 +171,6 @@ void TF2Tools::SDK_OnUnload() g_RegNatives.UnregisterAll(); gameconfs->CloseGameConfigFile(g_pGameConf); playerhelpers->UnregisterCommandTargetProcessor(this); - playerhelpers->RemoveClientListener(this); plsys->RemovePluginsListener(this); @@ -357,7 +355,7 @@ void TF2Tools::OnPluginLoaded(IPlugin *plugin) && ( g_addCondForward->GetFunctionCount() || g_removeCondForward->GetFunctionCount() ) ) { - m_CondChecksEnabled = InitialiseConditionChecks(); + m_CondChecksEnabled = g_CondMgr.Init(); } if (!m_RulesDetoursEnabled @@ -384,7 +382,7 @@ void TF2Tools::OnPluginUnloaded(IPlugin *plugin) { if (!g_addCondForward->GetFunctionCount() && !g_removeCondForward->GetFunctionCount()) { - RemoveConditionChecks(); + g_CondMgr.Shutdown(); m_CondChecksEnabled = false; } } @@ -403,11 +401,6 @@ void TF2Tools::OnPluginUnloaded(IPlugin *plugin) } } -void TF2Tools::OnClientPutInServer(int client) -{ - Conditions_OnClientPutInServer(client); -} - int FindResourceEntity() { return FindEntityByNetClass(-1, "CTFPlayerResource"); diff --git a/extensions/tf2/extension.h b/extensions/tf2/extension.h index 0f6b2089..d9b22334 100644 --- a/extensions/tf2/extension.h +++ b/extensions/tf2/extension.h @@ -2,7 +2,7 @@ * vim: set ts=4 : * ============================================================================= * SourceMod Team Fortress 2 Extension - * Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -55,8 +55,7 @@ class TF2Tools : public ICommandTargetProcessor, public IConCommandBaseAccessor, public IGameEventListener2, - public IPluginsListener, - public IClientListener + public IPluginsListener { public: //SDKExtension /** @@ -104,8 +103,6 @@ public: //IGameEventManager public: //IPluginsListener void OnPluginLoaded(IPlugin *plugin); void OnPluginUnloaded(IPlugin *plugin); -public: //IClientListener - void OnClientPutInServer(int client); public: #if defined SMEXT_CONF_METAMOD /** diff --git a/extensions/tf2/msvc10/tf2.sln b/extensions/tf2/msvc10/tf2.sln deleted file mode 100644 index 905d5273..00000000 --- a/extensions/tf2/msvc10/tf2.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tf2", "tf2.vcxproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/tf2/msvc10/tf2.vcxproj b/extensions/tf2/msvc10/tf2.vcxproj deleted file mode 100644 index 43b3679c..00000000 --- a/extensions/tf2/msvc10/tf2.vcxproj +++ /dev/null @@ -1,153 +0,0 @@ - - - - - Debug - Orange Box Valve - Win32 - - - Release - Orange Box Valve - Win32 - - - - {B3E8AF22-5436-49A4-9A3F-631519874372} - tf2 - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - game.tf2.ext.2.ep2v - - - game.tf2.ext.2.ep2v - - - - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKOBVALVE);$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - true - Windows - false - - - MachineX86 - false - /NODEFAULTLIB:LIBCMT - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKOBVALVE);$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="$(TargetFileName)";%(PreprocessorDefinitions) - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - true - Windows - true - true - false - - - MachineX86 - /NODEFAULTLIB:LIBCMT - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/tf2/msvc10/tf2.vcxproj.filters b/extensions/tf2/msvc10/tf2.vcxproj.filters deleted file mode 100644 index 464dbac1..00000000 --- a/extensions/tf2/msvc10/tf2.vcxproj.filters +++ /dev/null @@ -1,105 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {31958233-BB2D-4e41-A8F9-CE8A4684F436} - - - {3007f0ba-d54e-4475-9cd9-4de6b9231c2b} - - - {9ebb1d82-4b3c-4331-934e-654f40215478} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - SourceMod SDK - - - CDetour - - - asm - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - SourceMod SDK - - - SourceMod SDK - - - CDetour - - - CDetour - - - asm - - - Header Files - - - \ No newline at end of file diff --git a/extensions/tf2/natives.cpp b/extensions/tf2/natives.cpp index 4a1fabee..8dedfd04 100644 --- a/extensions/tf2/natives.cpp +++ b/extensions/tf2/natives.cpp @@ -41,11 +41,11 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params) { static ICallWrapper *pWrapper = NULL; - // CTFPlayerShared::MakeBleed(CTFPlayer*, CTFWeaponBase*, float, int=4) + // CTFPlayerShared::MakeBleed(CTFPlayer*, CTFWeaponBase*, float, int=4, bool=false) if(!pWrapper) { REGISTER_NATIVE_ADDR("MakeBleed", - PassInfo pass[4]; \ + PassInfo pass[5]; \ pass[0].flags = PASSFLAG_BYVAL; \ pass[0].size = sizeof(CBaseEntity *); \ pass[0].type = PassType_Basic; \ @@ -58,7 +58,10 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params) pass[3].flags = PASSFLAG_BYVAL; \ pass[3].size = sizeof(int); \ pass[3].type = PassType_Basic; \ - pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 4)) + pass[4].flags = PASSFLAG_BYVAL; \ + pass[4].size = sizeof(bool); \ + pass[4].type = PassType_Basic; \ + pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 5)) } CBaseEntity *pEntity; @@ -75,7 +78,7 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params) void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset); - unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float)]; + unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float) + sizeof(int) + sizeof(bool)]; unsigned char *vptr = vstk; *(void **)vptr = obj; @@ -87,6 +90,8 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params) *(float *)vptr = sp_ctof(params[3]); vptr += sizeof(float); *(int *)vptr = 4; + vptr += sizeof(int); + *(bool *)vptr = false; pWrapper->Execute(vstk, NULL); @@ -98,7 +103,7 @@ cell_t TF2_Burn(IPluginContext *pContext, const cell_t *params) { static ICallWrapper *pWrapper = NULL; - // CTFPlayerShared::Burn(CTFPlayer*, CTFWeaponBase*) + // CTFPlayerShared::Burn(CTFPlayer*, CTFWeaponBase*, float=-1.0) if (!pWrapper) { REGISTER_NATIVE_ADDR("Burn", @@ -129,7 +134,7 @@ cell_t TF2_Burn(IPluginContext *pContext, const cell_t *params) void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset); - unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *)]; + unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float)]; unsigned char *vptr = vstk; *(void **)vptr = obj; @@ -155,7 +160,7 @@ cell_t TF2_Disguise(IPluginContext *pContext, const cell_t *params) { static ICallWrapper *pWrapper = NULL; - //CTFPlayerShared::Disguise(int, int, CTFPlayer *) + //CTFPlayerShared::Disguise(int, int, CTFPlayer *, bool=true) if (!pWrapper) { REGISTER_NATIVE_ADDR("Disguise", @@ -190,7 +195,7 @@ cell_t TF2_Disguise(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Target client index %d is not valid", params[4]); } - unsigned char vstk[sizeof(void *) + 2*sizeof(int) + sizeof(bool)]; + unsigned char vstk[sizeof(void *) + 2*sizeof(int) + sizeof(CBaseEntity *) + sizeof(bool)]; unsigned char *vptr = vstk; diff --git a/extensions/topmenus/Makefile b/extensions/topmenus/Makefile deleted file mode 100644 index acb48ab8..00000000 --- a/extensions/topmenus/Makefile +++ /dev/null @@ -1,157 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -SRCDS_BASE = ~/srcds -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -MMSOURCE17 = ../../../mmsource-1.7 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = topmenus - -#Uncomment for Metamod: Source enabled extension -#USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp sdk/sm_memtable.cpp extension.cpp TopMenuManager.cpp \ - TopMenu.cpp smn_topmenus.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - SRCDS = $(SRCDS_BASE) - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=4 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=5 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d - override ENGSET = true -endif - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \ - -I$(MMSOURCE17)/core/sourcehook -endif - -LINK += -m32 -ldl -lm - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ - -Wno-unused -Wno-uninitialized -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \ - ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/topmenus/TopMenu.cpp b/extensions/topmenus/TopMenu.cpp index 2d21c07a..8d4738c5 100644 --- a/extensions/topmenus/TopMenu.cpp +++ b/extensions/topmenus/TopMenu.cpp @@ -80,12 +80,15 @@ TopMenu::~TopMenu() delete m_Config.cats[i]; } - /* Sweep players */ - for (size_t i = 0; i <= (size_t)m_max_clients; i++) + if (m_clients != NULL) { - TearDownClient(&m_clients[i]); + /* Sweep players */ + for (size_t i = 0; i <= (size_t)m_max_clients; i++) + { + TearDownClient(&m_clients[i]); + } + free(m_clients); } - free(m_clients); } unsigned int TopMenu::CalcMemUsage() diff --git a/extensions/topmenus/msvc10/topmenus.sln b/extensions/topmenus/msvc10/topmenus.sln deleted file mode 100644 index bf3fe2b4..00000000 --- a/extensions/topmenus/msvc10/topmenus.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "topmenus", "topmenus.vcxproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/topmenus/msvc10/topmenus.vcxproj b/extensions/topmenus/msvc10/topmenus.vcxproj deleted file mode 100644 index 8befb5ff..00000000 --- a/extensions/topmenus/msvc10/topmenus.vcxproj +++ /dev/null @@ -1,138 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {C701A837-4258-45D1-93EF-85EDBA7D924A} - topmenus - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - topmenus.ext - - - - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public;%(AdditionalIncludeDirectories) - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) - MultiThreaded - false - - - Level3 - ProgramDatabase - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public;%(AdditionalIncludeDirectories) - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/topmenus/msvc10/topmenus.vcxproj.filters b/extensions/topmenus/msvc10/topmenus.vcxproj.filters deleted file mode 100644 index 7c1833bb..00000000 --- a/extensions/topmenus/msvc10/topmenus.vcxproj.filters +++ /dev/null @@ -1,77 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {31958233-BB2D-4e41-A8F9-CE8A4684F436} - - - {a977cab9-f3d8-4f10-a411-66fe6e672b1a} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - SourceMod SDK - - - SourceMod SDK - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - SourceMod SDK - - - SourceMod SDK - - - SourceMod SDK - - - SourceMod SDK - - - Interfaces - - - - - Resource Files - - - \ No newline at end of file diff --git a/extensions/topmenus/msvc8/topmenus.sln b/extensions/topmenus/msvc8/topmenus.sln deleted file mode 100644 index 59d994d4..00000000 --- a/extensions/topmenus/msvc8/topmenus.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "topmenus", "topmenus.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/topmenus/msvc8/topmenus.vcproj b/extensions/topmenus/msvc8/topmenus.vcproj deleted file mode 100644 index 3ef567ec..00000000 --- a/extensions/topmenus/msvc8/topmenus.vcproj +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/topmenus/msvc9/topmenus.sln b/extensions/topmenus/msvc9/topmenus.sln deleted file mode 100644 index d6b05ae4..00000000 --- a/extensions/topmenus/msvc9/topmenus.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "topmenus", "topmenus.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/topmenus/msvc9/topmenus.vcproj b/extensions/topmenus/msvc9/topmenus.vcproj deleted file mode 100644 index bc36ac8b..00000000 --- a/extensions/topmenus/msvc9/topmenus.vcproj +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/updater/Makefile b/extensions/updater/Makefile deleted file mode 100644 index c72686d4..00000000 --- a/extensions/updater/Makefile +++ /dev/null @@ -1,161 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -SRCDS_BASE = ~/srcds -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -MMSOURCE17 = ../../../mmsource-1.7 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = updater - -#Uncomment for Metamod: Source enabled extension -#USEMETA = true - -OBJECTS = \ - sdk/smsdk_ext.cpp \ - extension.cpp \ - MemoryDownloader.cpp \ - md5.cpp \ - Updater.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -override ENGSET = false -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/linux_sdk - CFLAGS += -DSOURCE_ENGINE=1 - METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls - SRCDS = $(SRCDS_BASE) - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=3 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=4 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/orangebox - override ENGSET = true -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - HL2PUB = $(HL2SDK)/public - HL2LIB = $(HL2SDK)/lib/linux - CFLAGS += -DSOURCE_ENGINE=5 - METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d - override ENGSET = true -endif - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so - - LINK += $(LINK_HL2) - - INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -else - INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn \ - -I$(SMSDK)/public/extensions -I$(MMSOURCE17)/core/sourcehook -endif - -LINK += -m32 -lm -ldl - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \ - -Wno-unused -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).ext.dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).ext.so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \ - ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \ - fi - $(MAKE) -f Makefile extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ - exit 1; \ - fi - -extension: check $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/extensions/updater/msvc9/updater.sln b/extensions/updater/msvc9/updater.sln deleted file mode 100644 index 2e499e47..00000000 --- a/extensions/updater/msvc9/updater.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "updater", "updater.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/extensions/updater/msvc9/updater.vcproj b/extensions/updater/msvc9/updater.vcproj deleted file mode 100644 index fd38f39f..00000000 --- a/extensions/updater/msvc9/updater.vcproj +++ /dev/null @@ -1,926 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gamedata/core.games/blacklist.plugins.txt b/gamedata/core.games/blacklist.plugins.txt index acc5e0f6..5fb01071 100644 --- a/gamedata/core.games/blacklist.plugins.txt +++ b/gamedata/core.games/blacklist.plugins.txt @@ -25,10 +25,66 @@ "plugin_7b3ce69f15e61cc896228cb8424be589" "" /* UCP Server (Endi) - Version 7.8.2 */ "plugin_24602c74f183cfcd157b3d50dee96c52" "" /* UCP Server (Endi) - Version 7.8.3 */ "plugin_43bd225c5fdcd3af35729ca9d481b20d" "" /* UCP Server (Endi) - Version 8.3 */ + "plugin_aaeeeedeca7bdbdd630ddc5868daade7" "" /* UCP Server (Endi) - Version 8.4 */ "plugin_78140f1a0f26cd3297767d0598eac4b1" "" /* [Any] PReplay (DarthNinja) - Version 1.0.0 */ - "plugin_55923ba6bfe41569a3e4fbd7ca4606e5" "" /* VIP Plugin (World-Source.Ru) - Version 2.0 */ + "plugin_55923ba6bfe41569a3e4fbd7ca4606e5" "" /* VIP Plugin (wS) - Version 2.0 */ "plugin_4bf983e1d5b61ba0b1ab9a7e53bfda27" "" /* WarMod CS:GO (Twelve-60) */ "plugin_08574c4295afdaa5f613b8ceef96ecc3" "" /* AlliedBans (TommY) - Version 3.140902A */ + "plugin_035ef79cb06a3ebcfaf277641577fdc6" "" /* Ability Levels (wS) - Version v1.1.1 */ + "plugin_ce9183f87bf265408cb1c78534cc4863" "" /* Ability Levels Commands (wS) - Version 1.0.1 */ + "plugin_d6386cf822f095289b011ca2f47ae6c4" "" /* AdMiN (wS) - Version v2.3.1 */ + "plugin_02ef75b4af8c3f1d7998befdd8ed7586" "" /* Jail Control (wS) - Version v2.4.3 */ + "plugin_a0c93519819ad79c3c2e27830c7edeff" "" /* Knife Arena (wS) - Version 1.2.7 */ + "plugin_daf0ad0dd7c3aa732b9c1cb7a9cbb3cf" "" /* Round Start Effects (wS) - Version 1.2 */ + "plugin_c473a87937edf5967db777f1cf04f725" "" /* Continuous Attack (wS) - Version 1.0 */ + "plugin_12d7f2697110d4d67f33ca8b2a81c490" "" /* STORE (wS) - Version 2.1.5 */ + "plugin_d134bd59c6f8dc2b8df27be31fd966b1" "" /* STORE (Auction) (wS) - Version 1.0 */ + "plugin_159560d50105f9a58fa8a94de56c5fc4" "" /* STORE (Bhop) (wS) - Version 1.2 */ + "plugin_99d45e0bfd4d4fdd0513cd84c50dca31" "" /* STORE (Credits Giver) (wS) - Version 1.2 */ + "plugin_989d2075869168645c7a761ff41f69f6" "" /* STORE (Critical Grenade) (wS) - Version 1.1 */ + "plugin_34eddaa68248ff140daad09a58c619de" "" /* STORE (Double Jump) (wS) - Version 1.0 */ + "plugin_7bda86011e3365d90bee6dd88f213ae6" "" /* STORE (Enemy Skin) (wS) - Version 1.1 */ + "plugin_4f2b15a5b260936149a3123504c1ac7c" "" /* STORE (Gifts) (wS) - Version 1.2 */ + "plugin_c1b560cd688de12bebdeaa04999dc3d4" "" /* STORE (Gravity) (wS) - Version 1.1 */ + "plugin_79e80527430bba85d311a79cd729b914" "" /* STORE (Health) (wS) - Version 1.2 */ + "plugin_79fd13ceb7227c34571833a31d2a4957" "" /* STORE (Lasers) (wS) - Version 1.2 */ + "plugin_7c83004d88445d84bf4291fec678614d" "" /* STORE (Money) (wS) - Version 1.3 */ + "plugin_b98d853e0387ff44e4e58822949bb5f5" "" /* STORE (Respawn) (wS) - Version 1.2 */ + "plugin_d45ef7eb8ef26a46e6ea8e7dc2640ed5" "" /* STORE (Show Credits) (wS) - Version 1.3 */ + "plugin_624d31eecf19f9a4a7d87b7d2d2d14aa" "" /* STORE (Skins) (wS) - Version 1.2 */ + "plugin_8b2f4f60a77d1e81e6e7026ff6316920" "" /* STORE (Speed) (wS) - Version 1.2 */ + "plugin_643e1c5bf55c6ed10763dd46d4620aa4" "" /* STORE (Trails) (wS) - Version 1.2 */ + "plugin_b75c6ba4f569c57bc6df906f1a4dfd4f" "" /* STORE (Transfer Credits) (wS) - Version 1.2 */ + "plugin_93122ae52ae37c4a13eb9da25562e234" "" /* Teleporter (wS) - Version v1.0 */ + "plugin_41f8b0b9b67fa207acf229bdf6251765" "" /* VIP Module (Ammo) (wS) - Version 1.0 */ + "plugin_c9ff989b36ff12fcf3b8c93b42ada242" "" /* VIP Module (Anti Flash) (wS) - Version 1.1 */ + "plugin_3c9c13133eb8d83c2b4221ca102d90ac" "" /* VIP Module (Armor) (wS) - Version 1.0 */ + "plugin_b6eb66fe6fe44a907073825a02932317" "" /* VIP Module (Aura) (wS) - Version 1.1 */ + "plugin_d6e99dbf976f4011399075dd4e2c95a8" "" /* VIP Module (BHOP|Double Jump|Parachute) (wS) - Version 1.4.7 */ + "plugin_490fdd8bf0457878e89d383180c86e3d" "" /* VIP Module (Chat) (wS) - Version 1.2.1 */ + "plugin_1655ed45b5c016bcfd703f8bc59cee69" "" /* VIP Module (DMG Changer) (wS) - Version 1.1 */ + "plugin_0b194f78df428423927ba8868bcf3300" "" /* VIP Module (Drop Any Weapon) (wS) - Version 1.2 */ + "plugin_0e574d5ffaac4600cd883270b55dc30a" "" /* VIP Module (Flags|Immunity) (wS) - Version 1.1 */ + "plugin_a415a21bf430fa8b67b5ca73c9e46fb3" "" /* VIP Module (Gravity) (wS) - Version 1.1 */ + "plugin_57d0852c9619c20c57e8a1d6b6f6b9da" "" /* VIP Module (Grenade Explode Effect) (wS) - Version 1.1 */ + "plugin_ae385eb0ef6eaf12fb704051b17ac0e8" "" /* VIP Module (Grenade Model) (wS) - Version 1.0 */ + "plugin_1915c17c700c2d6dd0c543f04ffcfb5c" "" /* VIP Module (Grenade Trail) (wS) - Version 1.2 */ + "plugin_28c7754b3782b5b2f64243b5ac80088e" "" /* VIP Module (Hostage Rescue) (wS) - Version 1.0 */ + "plugin_e3f382addaf9d83201dae58e816222e9" "" /* VIP Module (HP Regen) (wS) - Version 1.1 */ + "plugin_8c6b5b2813dd289db3294346887d0160" "" /* VIP Module (Kill Cash) (wS) - Version 1.1 */ + "plugin_21d22920b63ab7683b86e36aae239996" "" /* VIP Module (Kill HP) (wS) - Version 1.1 */ + "plugin_7fb93bf5756a2d8542ca565d8d9aa65a" "" /* VIP Module (More Grenades) (wS) - Version 1.2.1 */ + "plugin_43af503aec909771eb5e71fd65a411bb" "" /* VIP Module (Quick Defuse) (wS) - Version 1.1 */ + "plugin_cf69750c2be3baf0fe6dd5dc21de257d" "" /* VIP Module (Reset Score) (wS) - Version 1.1 */ + "plugin_f50c61c3d3c2f1f1393272c84dbe798d" "" /* VIP Module (Respawn) (wS) - Version 1.1 */ + "plugin_43643c4b9ee9ed14fced7b06dd006e7f" "" /* VIP Module (Skins) (wS) - Version 1.2.5 */ + "plugin_831bb87c8882c5e17408717cc829c7b6" "" /* VIP Module (Smoke Aura) (wS) - Version 1.1 */ + "plugin_fd0550b620e4b280fbf5812478d97a0b" "" /* VIP Module (Speed) (wS) - Version 1.1 */ + "plugin_249d893b2f699b51a757f9a0f76408e3" "" /* VIP Module (Team) (wS) - Version 1.1 */ + "plugin_9bf46f7ecbf9a94fd4b3f922bb2f1003" "" /* VIP Module (Teleport) (wS) - Version 1.0 */ + "plugin_229bb55fb7f4d9e6df47682847201031" "" /* VIP Test (wS) - Version 1.2 */ + "plugin_4a9943bb6c831c605c3e4aef38d9c789" "" /* VIP Module (Trails) (wS) - Version 1.2 */ + "plugin_2296f1162a2f1886fcad5601c1597835" "" /* VIP (!vips) (wS) - Version 1.2.1 */ } } } diff --git a/gamedata/core.games/common.games.txt b/gamedata/core.games/common.games.txt index 4d7b31f3..c2628596 100644 --- a/gamedata/core.games/common.games.txt +++ b/gamedata/core.games/common.games.txt @@ -39,6 +39,14 @@ } } + "fof" + { + "Keys" + { + "m_iHealth" "m_hYFD2" + } + } + /* Original engine specifics */ "#default" { @@ -100,6 +108,7 @@ "engine" "dota" "engine" "sdk2013" "engine" "contagion" + "engine" "bms" } "Offsets" @@ -236,6 +245,7 @@ "game" "berimbau" "game" "cstrike" "game" "synergy" + "game" "bms" } "Keys" diff --git a/gamedata/core.games/engine.bms.txt b/gamedata/core.games/engine.bms.txt new file mode 100644 index 00000000..c294790d --- /dev/null +++ b/gamedata/core.games/engine.bms.txt @@ -0,0 +1,31 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your SourceMod 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 SM's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(SourceMod) + */ + +"Games" +{ + "#default" + { + "Keys" + { + "UseInvalidUniverseInSteam2IDs" "1" + } + + "Offsets" + { + "EntInfo" + { + "windows" "4" + "linux" "4" + "mac" "4" + } + } + } +} diff --git a/gamedata/core.games/master.games.txt b/gamedata/core.games/master.games.txt index c6b29853..0bb61480 100644 --- a/gamedata/core.games/master.games.txt +++ b/gamedata/core.games/master.games.txt @@ -50,6 +50,11 @@ "engine" "sdk2013" } + "engine.bms.txt" + { + "engine" "bms" + } + "engine.css.txt" { "engine" "css" diff --git a/gamedata/sdkhooks.games/engine.csgo.txt b/gamedata/sdkhooks.games/engine.csgo.txt index 021c46f0..120fdc84 100644 --- a/gamedata/sdkhooks.games/engine.csgo.txt +++ b/gamedata/sdkhooks.games/engine.csgo.txt @@ -47,17 +47,17 @@ "mac" "294" } "PreThink" - { - "windows" "365" - "linux" "366" - "mac" "366" - } - "PostThink" { "windows" "366" "linux" "367" "mac" "367" } + "PostThink" + { + "windows" "367" + "linux" "368" + "mac" "368" + } "Reload" { "windows" "308" diff --git a/gamedata/sdkhooks.games/game.bms.txt b/gamedata/sdkhooks.games/game.bms.txt new file mode 100644 index 00000000..13cc7346 --- /dev/null +++ b/gamedata/sdkhooks.games/game.bms.txt @@ -0,0 +1,129 @@ +"Games" +{ + "#default" + { + "Offsets" + { + "Blocked" + { + "windows" "108" + "linux" "109" + "mac" "109" + } + "EndTouch" + { + "windows" "106" + "linux" "107" + "mac" "107" + } + "FireBullets" + { + "windows" "119" + "linux" "120" + "mac" "120" + } + "OnTakeDamage" + { + "windows" "66" + "linux" "67" + "mac" "67" + } + "OnTakeDamage_Alive" + { + "windows" "287" + "linux" "288" + "mac" "288" + } + "PreThink" + { + "windows" "349" + "linux" "350" + "mac" "350" + } + "PostThink" + { + "windows" "350" + "linux" "351" + "mac" "351" + } + "SetTransmit" + { + "windows" "20" + "linux" "21" + "mac" "21" + } + "ShouldCollide" + { + "windows" "16" + "linux" "17" + "mac" "17" + } + "Spawn" + { + "windows" "22" + "linux" "23" + "mac" "23" + } + "StartTouch" + { + "windows" "104" + "linux" "105" + "mac" "105" + } + "Think" + { + "windows" "48" + "linux" "49" + "mac" "49" + } + "Touch" + { + "windows" "105" + "linux" "106" + "mac" "106" + } + "TraceAttack" + { + "windows" "64" + "linux" "65" + "mac" "65" + } + "VPhysicsUpdate" + { + "windows" "155" + "linux" "156" + "mac" "156" + } + "Weapon_CanSwitchTo" + { + "windows" "281" + "linux" "282" + "mac" "282" + } + "Weapon_CanUse" + { + "windows" "275" + "linux" "276 + "mac" "276" + } + "Weapon_Drop" + { + "windows" "278" + "linux" "279" + "mac" "279" + } + "Weapon_Equip" + { + "windows" "276" + "linux" "277" + "mac" "277" + } + "Weapon_Switch" + { + "windows" "279" + "linux" "280" + "mac" "280" + } + } + } +} \ No newline at end of file diff --git a/gamedata/sdkhooks.games/master.games.txt b/gamedata/sdkhooks.games/master.games.txt index aefdfa85..0d45ef4a 100644 --- a/gamedata/sdkhooks.games/master.games.txt +++ b/gamedata/sdkhooks.games/master.games.txt @@ -179,4 +179,9 @@ { "game" "hl2ctf" } + + "game.bms.txt" + { + "game" "bms" + } } diff --git a/gamedata/sdktools.games/engine.bgt.txt b/gamedata/sdktools.games/engine.bgt.txt index 3465c6e3..9ad41086 100644 --- a/gamedata/sdktools.games/engine.bgt.txt +++ b/gamedata/sdktools.games/engine.bgt.txt @@ -119,6 +119,15 @@ "windows" "17" } + /** + * CBaseClient::SetName(char const*); + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + } + /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.blade.txt b/gamedata/sdktools.games/engine.blade.txt index 5dbe09d5..32da0ee0 100644 --- a/gamedata/sdktools.games/engine.blade.txt +++ b/gamedata/sdktools.games/engine.blade.txt @@ -210,6 +210,17 @@ "linux" "64" "mac" "64" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + "linux" "63" + "mac" "63" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.contagion.txt b/gamedata/sdktools.games/engine.contagion.txt index 697bb724..2b81c543 100644 --- a/gamedata/sdktools.games/engine.contagion.txt +++ b/gamedata/sdktools.games/engine.contagion.txt @@ -169,6 +169,17 @@ "linux" "63" "mac" "63" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + "linux" "62" + "mac" "62" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.csgo.txt b/gamedata/sdktools.games/engine.csgo.txt index 19ca6dc5..c3eb9968 100644 --- a/gamedata/sdktools.games/engine.csgo.txt +++ b/gamedata/sdktools.games/engine.csgo.txt @@ -189,6 +189,17 @@ "SetUserCvar" { /* Not 100% sure on this, why would windows change and not linux - TEST ME */ + "windows" "28" + "linux" "65" + "mac" "65" + } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { "windows" "27" "linux" "64" "mac" "64" @@ -221,9 +232,9 @@ { "GiveNamedItem" { - "windows" "445" - "linux" "446" - "mac" "446" + "windows" "446" + "linux" "447" + "mac" "447" } "RemovePlayerItem" { @@ -257,9 +268,9 @@ } "CommitSuicide" { - "windows" "495" - "linux" "495" - "mac" "495" + "windows" "496" + "linux" "496" + "mac" "496" } "GetVelocity" { @@ -299,9 +310,9 @@ } "PlayerRunCmd" { - "windows" "465" - "linux" "466" - "mac" "466" + "windows" "466" + "linux" "467" + "mac" "467" } "GiveAmmo" { diff --git a/gamedata/sdktools.games/engine.css.txt b/gamedata/sdktools.games/engine.css.txt index eaae257c..a77d2a0b 100644 --- a/gamedata/sdktools.games/engine.css.txt +++ b/gamedata/sdktools.games/engine.css.txt @@ -157,6 +157,17 @@ "linux" "58" "mac" "58" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "17" + "linux" "57" + "mac" "57" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.darkm.txt b/gamedata/sdktools.games/engine.darkm.txt index 0af568c2..27acd6f4 100644 --- a/gamedata/sdktools.games/engine.darkm.txt +++ b/gamedata/sdktools.games/engine.darkm.txt @@ -189,6 +189,15 @@ { "windows" "17" } + + /** + * CBaseClient::SetName(char const*); + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + } "UpdateUserSettings" { @@ -262,6 +271,10 @@ { "windows" "32" } + "PlayerRunCmd" + { + "windows" "327" + } } "Signatures" diff --git a/gamedata/sdktools.games/engine.dota.txt b/gamedata/sdktools.games/engine.dota.txt index 2713e866..fa858e35 100644 --- a/gamedata/sdktools.games/engine.dota.txt +++ b/gamedata/sdktools.games/engine.dota.txt @@ -218,6 +218,17 @@ "SetUserCvar" { "windows" "26" + "linux" "63" + "mac" "63" + } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "25" "linux" "62" "mac" "62" } diff --git a/gamedata/sdktools.games/engine.ep1.txt b/gamedata/sdktools.games/engine.ep1.txt index a2d2c1fc..ab234e03 100644 --- a/gamedata/sdktools.games/engine.ep1.txt +++ b/gamedata/sdktools.games/engine.ep1.txt @@ -254,6 +254,16 @@ "windows" "17" "linux" "53" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + "linux" "52" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.ep2.txt b/gamedata/sdktools.games/engine.ep2.txt index 07e9c9b2..887b2185 100644 --- a/gamedata/sdktools.games/engine.ep2.txt +++ b/gamedata/sdktools.games/engine.ep2.txt @@ -219,6 +219,16 @@ "windows" "17" "linux" "55" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + "linux" "54" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.ep2valve.txt b/gamedata/sdktools.games/engine.ep2valve.txt index 544b6028..fc9dd6c9 100644 --- a/gamedata/sdktools.games/engine.ep2valve.txt +++ b/gamedata/sdktools.games/engine.ep2valve.txt @@ -162,6 +162,17 @@ "linux" "58" "mac" "58" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "17" + "linux" "57" + "mac" "57" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.eye.txt b/gamedata/sdktools.games/engine.eye.txt index a600d8ff..c31b3b81 100644 --- a/gamedata/sdktools.games/engine.eye.txt +++ b/gamedata/sdktools.games/engine.eye.txt @@ -149,6 +149,14 @@ { "windows" "17" } + /** + * CBaseClient::SetName(char const*); + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.insurgency.txt b/gamedata/sdktools.games/engine.insurgency.txt index ef05ade1..13c0b896 100644 --- a/gamedata/sdktools.games/engine.insurgency.txt +++ b/gamedata/sdktools.games/engine.insurgency.txt @@ -35,7 +35,7 @@ /* Offset into CBaseTempEntity constructor */ "s_pTempEntities" { - "windows" "19" + "windows" "16" } "GetTEName" { @@ -62,7 +62,7 @@ "CBaseTempEntity" { "library" "server" - "windows" "\x55\x8B\xEC\x8B\xC1\x8B\x4D\x08\xC7\x00\x2A\x2A\x2A\x2A\x89\x48\x2A\x8B" + "windows" "\x55\x8B\xEC\x8B\x45\x08\x89\x41\x04\xC7\x01\x2A\x2A\x2A\x2A\xA1" } "s_pTempEntities" { @@ -82,7 +82,7 @@ "FindEntityByClassname" { "library" "server" - "windows" "\x55\x8B\xEC\x53\x56\x8B\xF1\x8B\x4D\x08\x57\x85\xC9\x74\x2A\x8B\x01\x8B\x50\x08\xFF\xD2\x8B\x00\x83\xF8\xFF\x75\x2A\xB8\xFF\x1F\x00\x00\x8D\x04\x40\x8B\x74\xC6\x2A\xEB" + "windows" "\x55\x8B\xEC\x53\x56\x8B\xF1\x8B\x4D\x08\x57\x85\xC9\x74\x26\x8B\x01\xFF\x50\x08\x8B\x00\x83\xF8\xFF\x75\x0E\xB8\xFF\x1F\x00\x00\x8D\x04\x40\x8B\x74\xC6\x10\xEB\x12\x0F\xB7\xC0\x8D\x04\x40\x8B\x74\xC6\x10\xEB\x06\x8B\xB6\x2A\x2A\x2A\x2A\x85\xF6\x74\x4C" "linux" "@_ZN17CGlobalEntityList21FindEntityByClassnameEP11CBaseEntityPKc" "mac" "@_ZN17CGlobalEntityList21FindEntityByClassnameEP11CBaseEntityPKc" } @@ -102,7 +102,7 @@ /* Offset into CreateGameRulesObject */ "g_pGameRules" { - "windows" "2" + "windows" "5" } } @@ -119,7 +119,7 @@ "CreateGameRulesObject" { "library" "server" - "windows" "\x8B\x0D\x2A\x2A\x2A\x2A\x85\xC9\x74\x2A\x8B\x01\x8B\x50\x2A\x6A\x01\xFF\xD2" + "windows" "\x55\x8B\xEC\x8B\x0D\x2A\x2A\x2A\x2A\x85\xC9\x74\x07\x8B" } "g_pGameRules" { @@ -130,43 +130,6 @@ } } - /* IServer interface pointer */ - "#default" - { - "Keys" - { - /* Signature for the beginning of IVEngineServer::CreateFakeClient. - * - * The engine binary is not actually scanned in order to look for - * this. SourceHook is used to used to determine the address of the - * function and this signature is used to verify that it contains - * the expected code. A pointer to sv (IServer interface) is used - * here. - */ - "CreateFakeClient_Windows" "\x55\x8B\xEC\x8B\x2A\x2A\x50\xB9\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x85\xC0\x75" - } - - "Offsets" - { - /* Offset into IVEngineServer::CreateFakeClient */ - "sv" - { - "windows" "8" - } - } - - "Signatures" - { - /* CBaseServer object for IServer interface */ - "sv" - { - "library" "engine" - "linux" "@sv" - "mac" "@sv" - } - } - } - /* EntityFactoryDictionary function */ "#default" { @@ -175,7 +138,7 @@ "EntityFactory" { "library" "server" - "windows" "\xB8\x01\x00\x00\x00\x84\x2A\x2A\x2A\x2A\x2A\x75\x1D\x09\x2A\x2A\x2A\x2A\x2A\xB9\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x68\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x83\xC4\x04\xB8\x2A\x2A\x2A\x2A\xC3" + "windows" "\xA1\x2A\x2A\x2A\x2A\xA8\x01\x75\x1F\x83\xC8\x01\xB9\x2A\x2A\x2A\x2A\xA3\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x68\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x83\xC4\x04\xB8" "linux" "@_Z23EntityFactoryDictionaryv" "mac" "@_Z23EntityFactoryDictionaryv" } @@ -190,7 +153,7 @@ "FireOutput" { "library" "server" - "windows" "\x55\x8B\xEC\x81\x2A\x2A\x2A\x2A\x2A\x53\x56\x8B\x71\x2A\x57" + "windows" "\x55\x8B\xEC\x81\xEC\x2A\x2A\x2A\x2A\x53\x8B\xC1\xC7\x45\x2A\x2A\x2A\x2A\x00\x56\x57\x89" "linux" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f" "mac" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f" } @@ -214,6 +177,17 @@ "linux" "67" "mac" "67" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "19" + "linux" "66" + "mac" "66" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.l4d.txt b/gamedata/sdktools.games/engine.l4d.txt index e8dd87fa..d772b2e7 100644 --- a/gamedata/sdktools.games/engine.l4d.txt +++ b/gamedata/sdktools.games/engine.l4d.txt @@ -185,6 +185,17 @@ "linux" "63" "mac" "63" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + "linux" "62" + "mac" "62" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.l4d2.txt b/gamedata/sdktools.games/engine.l4d2.txt index 4a6e8502..d3a28af8 100644 --- a/gamedata/sdktools.games/engine.l4d2.txt +++ b/gamedata/sdktools.games/engine.l4d2.txt @@ -60,6 +60,17 @@ "linux" "63" "mac" "63" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + "linux" "62" + "mac" "62" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.sdk2013.txt b/gamedata/sdktools.games/engine.sdk2013.txt index f6a1fbc3..29c73df1 100644 --- a/gamedata/sdktools.games/engine.sdk2013.txt +++ b/gamedata/sdktools.games/engine.sdk2013.txt @@ -91,6 +91,17 @@ "linux" "58" "mac" "58" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "17" + "linux" "57" + "mac" "57" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/engine.swarm.txt b/gamedata/sdktools.games/engine.swarm.txt index 73e443ac..07789241 100644 --- a/gamedata/sdktools.games/engine.swarm.txt +++ b/gamedata/sdktools.games/engine.swarm.txt @@ -144,6 +144,14 @@ /* Not 100% sure on this, why would windows change and not linux - TEST ME */ "windows" "17" } + /** + * CBaseClient::SetName(char const*); + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/game.bms.txt b/gamedata/sdktools.games/game.bms.txt new file mode 100644 index 00000000..c29bf8ed --- /dev/null +++ b/gamedata/sdktools.games/game.bms.txt @@ -0,0 +1,200 @@ +/** + * Do not edit this file. Any changes will be overwritten by the gamedata + * updater or by upgrading your SourceMod 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 SM's own. + * + * For more information, see http://wiki.alliedmods.net/Gamedata_Updating_(SourceMod) + */ + +"Games" +{ + /* General Temp Entities */ + "#default" + { + "Offsets" + { + "GetTEName" + { + "windows" "4" + "linux" "4" + "mac" "4" + } + "GetTENext" + { + "windows" "8" + "linux" "8" + "mac" "8" + } + "TE_GetServerClass" + { + "windows" "0" + "linux" "0" + "mac" "0" + } + } + } + + /* CBaseEntityOutput::FireOutput */ + "#default" + { + "Signatures" + { + "FireOutput" + { + "library" "server" + "windows" "\x55\x8B\xEC\x81\xEC\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x33\xC5\x89\x45\xFC\x53\x8B\x5D\x20\x8B\xC1\x8B\x4D\x1C\x56\x57\x8B" + "linux" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f" + "mac" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f" + } + } + } + + /* SetUserInfo data */ + "#default" + { + "Offsets" + { + /** + * CBaseClient::SetUserCVar(char const*,char const*); + * Linux offset straight from VTable dump. + * Windows offset is crazy. Found the windows SetName function using string "(%d)%-0.*s" + * Cross referenced back to the vtable and counted manually (SetUserCvar is 1 higher, offsets start from 1) + */ + "SetUserCvar" + { + "windows" "18" + "linux" "58" + "mac" "58" + } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "17" + "linux" "57" + "mac" "57" + } + /** + * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. + * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. + * Linux: mov byte ptr [esi+98h], 0 + * Win: mov byte ptr [esi+0A4h], 0 + */ + "InfoChanged" + { + "windows" "140" + "linux" "140" + "mac" "140" + } + } + } + + "#default" + { + "Offsets" + { + "GiveNamedItem" + { + "windows" "418" + "linux" "419" + "mac" "419" + } + "RemovePlayerItem" + { + "windows" "285" + "linux" "286" + "mac" "286" + } + "Weapon_GetSlot" + { + "windows" "283" + "linux" "284" + "mac" "284" + } + "Ignite" + { + "windows" "222" + "linux" "223" + "mac" "223" + } + "Extinguish" + { + "windows" "226" + "linux" "227" + "mac" "227" + } + "Teleport" + { + "windows" "115" + "linux" "116" + "mac" "116" + } + "CommitSuicide" + { + "windows" "458" + "linux" "458" + "mac" "458" + } + "GetVelocity" + { + "windows" "148" + "linux" "149" + "mac" "149" + } + "EyeAngles" + { + "windows" "138" + "linux" "139" + "mac" "139" + } + "SetEntityModel" + { + "windows" "24" + "linux" "25" + "mac" "25" + } + "AcceptInput" + { + "windows" "37" + "linux" "38" + "mac" "38" + } + "WeaponEquip" + { + "windows" "276" + "linux" "277" + "mac" "277" + } + "Activate" + { + "windows" "34" + "linux" "35" + "mac" "35" + } + "PlayerRunCmd" + { + "windows" "437" + "linux" "438" + "mac" "438" + } + "GiveAmmo" + { + "windows" "267" + "linux" "268" + "mac" "268" + } + } + + "Keys" + { + "GameRulesProxy" "CTFGameRulesProxy" + "GameRulesDataTable" "tf_gamerules_data" + } + } +} diff --git a/gamedata/sdktools.games/game.ff.txt b/gamedata/sdktools.games/game.ff.txt index 8870c45f..095c2f73 100644 --- a/gamedata/sdktools.games/game.ff.txt +++ b/gamedata/sdktools.games/game.ff.txt @@ -108,17 +108,17 @@ "FindEntityByClassname" { "library" "server" - "windows" "\x53\x55\x56\x8B\xF1\x8B\x4C\x24\x10\x85\xC9\x57\x74\x19\x8B\x01\x8B\x50\x08\xFF\xD2\x8B\x00\x25\xFF\x0F\x00\x00\x83\xC0\x01\xC1\xE0\x04\x8B\x3C\x30\xEB\x06\x8B\xBE\x04\x00\x01\x00\x85\xFF\x74\x39\x8B\x5C\x24\x18\x8B\x2D\x2A\x2A\x2A\x2A\xEB\x03" + "windows" "\x53\x55\x56\x8B\xF1\x8B\x4C\x24\x10\x85\xC9\x57\x74\x2A\x8B\x01\x8B\x50\x08\xFF\xD2\x8B\x00\x25\xFF\x0F\x00\x00\x83\xC0\x01\xC1\xE0\x04\x8B\x3C\x30\xEB\x2A\x8B\xBE\x04\x00\x01\x00\x85\xFF\x74\x2A\x8B\x5C\x24\x18\x8B\x2D\x2A\x2A\x2A\x2A\xEB\x2A\x8D\x49\x00\x8B\x37\x85\xF6\x75\x2A\x68\x2A\x2A\x2A\x2A\xFF\xD5\x83\xC4\x04\xEB\x2A\x39\x5E\x34\x74\x2A\x53\x8B\xCE\xE8\x2A\x2A\x2A\x2A\x84\xC0" } "DispatchSpawn" { "library" "server" - "windows" "\x53\x55\x56\x8B\x74\x24\x10\x85\xF6\x57\x0F\x84\x2A\x2A\x2A\x2A\x8B\x1D\x2A\x2A\x2A\x2A\x8B\x03\x8B\x50\x60\x8B\xCB" + "windows" "\x53\x55\x56\x8B\x74\x24\x10\x85\xF6\x57\x0F\x84\x2A\x2A\x2A\x2A\x8B\x1D\x2A\x2A\x2A\x2A\x8B\x03" } "CreateEntityByName" { "library" "server" - "windows" "\x56\x8B\x74\x24\x0C\x83\xFE\xFF\x57\x8B\x7C\x24\x0C\x74\x27\x8B\x0D\x2A\x2A\x2A\x2A\x8B\x01\x8B\x50\x54\x56\xFF\xD2" + "windows" "\x56\x8B\x74\x24\x0C\x83\xFE\xFF\x57\x8B\x7C\x2A\x2A\x74\x2A\x8B\x0D\x2A\x2A\x2A\x2A\x8B\x01\x8B" } "FireOutput" { diff --git a/gamedata/sdktools.games/game.nucleardawn.txt b/gamedata/sdktools.games/game.nucleardawn.txt index 591ff363..406e5b2f 100644 --- a/gamedata/sdktools.games/game.nucleardawn.txt +++ b/gamedata/sdktools.games/game.nucleardawn.txt @@ -119,6 +119,17 @@ "linux" "63" "mac" "63" } + /** + * CBaseClient::SetName(char const*); + * Linux offset straight from VTable dump. + * Has string "(%d)%-0.*s" + */ + "SetClientName" + { + "windows" "16" + "linux" "62" + "mac" "62" + } /** * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. diff --git a/gamedata/sdktools.games/master.games.txt b/gamedata/sdktools.games/master.games.txt index b0926386..2f2e550a 100644 --- a/gamedata/sdktools.games/master.games.txt +++ b/gamedata/sdktools.games/master.games.txt @@ -243,4 +243,8 @@ { "game" "nmrih" } + "game.bms.txt" + { + "game" "bms" + } } diff --git a/gamedata/sm-cstrike.games/game.csgo.txt b/gamedata/sm-cstrike.games/game.csgo.txt index ac0c4f93..8f032413 100644 --- a/gamedata/sm-cstrike.games/game.csgo.txt +++ b/gamedata/sm-cstrike.games/game.csgo.txt @@ -13,6 +13,10 @@ { "csgo" { + "Keys" + { + "GetWeaponPriceByteCheck" "E9" + } "Offsets" { //Offset of szClassName in CCSWeaponInfo @@ -52,7 +56,7 @@ //Offset into HandleCommand_Buy_Internal "CCSPlayerInventoryOffset" { - "windows" "285" + "windows" "55" "linux" "32" "mac" "109" } @@ -62,6 +66,15 @@ "linux" "9" "mac" "9" } + "GetWeaponPriceFunc" + { + "windows" "84" + } + //This is GetWeaponPriceFunc offset -1 (only used by GDC) + "GetWeaponPriceFuncGDC" + { + "windows" "83" + } } "Signatures" { @@ -82,7 +95,7 @@ "HandleCommand_Buy_Internal"//Wildcard first 6 bytes for getting address for weapon price. { "library" "server" - "windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x81\xEC\x2A\x2A\x2A\x2A\x83\x3D\x2A\x2A\x2A\x2A\x00\x53\x56\x57\x8B\xF9" + "windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x81\xEC\x64\x01\x00\x00\x53\x56\x57\x6A\x00\x8B\xF9\xE8\x2A\x2A\x2A\x2A\x33\xC9\x84\xC0" "linux" "@_ZN9CCSPlayer26HandleCommand_Buy_InternalEPKcib" "mac" "@_ZN9CCSPlayer26HandleCommand_Buy_InternalEPKcib" } @@ -96,7 +109,7 @@ "TerminateRound" { "library" "server" - "windows" "\x55\x8B\xEC\x83\x2A\x2A\x83\x2A\x2A\x53\x56\x57\x8B\xF9\xF3\x0F\x2A\x2A\x2A\x2A\x33\xDB\xC7\x2A\x2A\x2A\x00\x00\x00\x00\x89" + "windows" "\x55\x8B\xEC\x83\xE4\xF8\x83\xEC\x3C\x53\x8B\xD9\xF3\x0F\x11\x4C\x24\x18\x56\x57\x89\x2A\x2A\x2A\x83" "linux" "@_ZN12CCSGameRules14TerminateRoundEfi" "mac" "@_ZN12CCSGameRules14TerminateRoundEfi" } @@ -143,13 +156,13 @@ "linux" "@_ZN9CCSPlayer10SetClanTagEPKc" "mac" "@_ZN9CCSPlayer10SetClanTagEPKc" } - //Wild card first 6 bytes since we call it and detour it. - "GetAttributeInt" + //In windows this is CCSPlayer::GetWeaponPrice NOT CCSWeaponInfo::GetWeaponPrice + "GetWeaponPrice" { "library" "server" - "windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x83\xEC\x1C\x53\x8B\x5D\x0C\xC7\x44\x24\x04\x00\x00\x00\x00\x56\x8B\xF1\x89\x74\x24\x0C\x57\x8B\x7D\x08\x85\xDB\x74\x2A\x80\x7B\x2A\x2A\x74\x2A\xE8\x2A\x2A\x2A\x2A\x57" - "linux" "@_ZNK16FileWeaponInfo_t15GetAttributeIntEPKcPK13CEconItemView" - "mac" "@_ZNK16FileWeaponInfo_t15GetAttributeIntEPKcPK13CEconItemView" + "windows" "\x55\x8B\xEC\x8B\xD1\x8B\x4D\x08\x83\xF9\x33\x75\x2A\x83\xBA" + "linux" "@_ZNK13CCSWeaponInfo14GetWeaponPriceEPK13CEconItemViewif" + "mac" "@_ZNK13CCSWeaponInfo14GetWeaponPriceEPK13CEconItemViewif" } "SetModelFromClass" { diff --git a/gamedata/sm-tf2.games.txt b/gamedata/sm-tf2.games.txt index eaafe74f..8bb17826 100644 --- a/gamedata/sm-tf2.games.txt +++ b/gamedata/sm-tf2.games.txt @@ -81,9 +81,9 @@ "MakeBleed" { "library" "server" - "windows" "\x55\x8B\xEC\x83\xEC\x20\x56\x8B\xF1\x89\x75\xF8\x8B\x8E" - "linux" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefi" - "mac" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefi" + "windows" "\x55\x8B\xEC\x83\xEC\x24\x56\x8B\xF1\x89\x75\xF8\x8B\x8E\x2A\x2A\x2A\x2A\x8B\x01" + "linux" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefib" + "mac" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefib" } "IsPlayerInDuel" { @@ -118,17 +118,17 @@ "mac" "326" } "CalcIsAttackCriticalHelper" - { - "windows" "384" - "linux" "391" - "mac" "391" - } - "CalcIsAttackCriticalHelperNoCrits" { "windows" "385" "linux" "392" "mac" "392" } + "CalcIsAttackCriticalHelperNoCrits" + { + "windows" "386" + "linux" "393" + "mac" "393" + } // CTFGameRules::IsHolidayActive "IsHolidayActive" diff --git a/knight/shared/KeCodeAllocator.cpp b/knight/shared/KeCodeAllocator.cpp deleted file mode 100644 index 976094fd..00000000 --- a/knight/shared/KeCodeAllocator.cpp +++ /dev/null @@ -1,423 +0,0 @@ -#include -#include -#include - -#if defined KE_PLATFORM_WINDOWS -#include -#elif defined KE_PLATFORM_POSIX -#include -#include -#include -#else -#error "TODO" -#endif - -#include "KeCodeAllocator.h" - -#define ALIGNMENT 16 - -using namespace Knight; - -struct KeFreedCode; - -/** - * Defines a region of memory that is made of pages. - */ -struct KeCodeRegion -{ - KeCodeRegion *next; - unsigned char *block_start; - unsigned char *block_pos; - KeFreedCode *free_list; - size_t total_size; - size_t end_free; - size_t total_free; -}; - -/** - * Defines freed code. We keep the size here because - * when we touch the linked list we don't want to dirty pages. - */ -struct KeFreedCode -{ - KeCodeRegion *region; - unsigned char *block_start; - size_t size; - KeFreedCode *next; -}; - -struct KeSecret -{ - KeCodeRegion *region; - size_t size; -}; - -class Knight::KeCodeCache -{ -public: - /** - * First region that is live for use. - */ - KeCodeRegion *first_live; - - /** - * First region that is full but has free entries. - */ - KeCodeRegion *first_partial; - - /** - * First region that is full. - */ - KeCodeRegion *first_full; - - /** - * Page granularity and size. - */ - unsigned int page_size; - unsigned int page_granularity; - - /** - * This isn't actually for code, this is the node cache. - */ - KeCodeRegion *node_cache; - KeFreedCode *free_node_list; -}; - -KeCodeCache *Knight::KE_CreateCodeCache() -{ - KeCodeCache *cache; - - cache = new KeCodeCache; - - memset(cache, 0, sizeof(KeCodeCache)); - -#if defined KE_PLATFORM_WINDOWS - SYSTEM_INFO info; - - GetSystemInfo(&info); - cache->page_size = info.dwPageSize; - cache->page_granularity = info.dwAllocationGranularity; -#else - cache->page_size = cache->page_granularity = sysconf(_SC_PAGESIZE); -#endif - - return cache; -} - -inline size_t MinAllocSize() -{ - size_t size; - - size = sizeof(KeSecret); - size += ALIGNMENT; - size -= size % ALIGNMENT; - - return size; -} - -inline size_t ke_GetAllocSize(size_t size) -{ - size += sizeof(KeSecret); - size += ALIGNMENT; - size -= size % ALIGNMENT; - - return size; -} - -void *ke_AllocInRegion(KeCodeCache *cache, - KeCodeRegion **prev, - KeCodeRegion *region, - unsigned char *ptr, - size_t alloc_size, - bool is_live) -{ - KeSecret *secret; - - /* Squirrel some info in the alloc. */ - secret = (KeSecret *)ptr; - secret->region = region; - secret->size = alloc_size; - ptr += sizeof(KeSecret); - - region->total_free -= alloc_size; - - /* Check if we can't use the fast-path anymore. */ - if ((is_live && region->end_free < MinAllocSize()) - || (!is_live && region->total_free < MinAllocSize())) - { - KeCodeRegion **start; - - *prev = region->next; - - /* Select the appropriate arena. */ - if (is_live) - { - if (region->total_free < MinAllocSize()) - { - start = &cache->first_full; - } - else - { - start = &cache->first_partial; - } - } - else - { - start = &cache->first_full; - } - - region->next = *start; - *start = region; - } - - return ptr; -} - -void *ke_AllocFromLive(KeCodeCache *cache, size_t size) -{ - void *ptr; - size_t alloc_size; - KeCodeRegion *region, **prev; - - region = cache->first_live; - prev = &cache->first_live; - alloc_size = ke_GetAllocSize(size); - - while (region != NULL) - { - if (region->end_free >= alloc_size) - { - /* Yay! We can do a simple alloc here. */ - ptr = ke_AllocInRegion(cache, prev, region, region->block_pos, alloc_size, true); - - /* Update our counters. */ - region->block_pos += alloc_size; - region->end_free -= alloc_size; - - return ptr; - } - prev = ®ion->next; - region = region->next; - } - - return NULL; -} - -void *ke_AllocFromPartial(KeCodeCache *cache, size_t size) -{ - void *ptr; - size_t alloc_size; - KeCodeRegion *region, **prev; - - region = cache->first_partial; - prev = &cache->first_partial; - alloc_size = ke_GetAllocSize(size); - - while (region != NULL) - { - if (region->total_free >= alloc_size) - { - KeFreedCode *node, **last; - - assert(region->free_list != NULL); - - last = ®ion->free_list; - node = region->free_list; - while (node != NULL) - { - if (node->size >= alloc_size) - { - /* Use this node */ - ptr = ke_AllocInRegion(cache, prev, region, node->block_start, alloc_size, false); - - region->total_free -= node->size; - *last = node->next; - - /* Make sure bookkeepping is correct. */ - assert((region->free_list == NULL && region->total_free == 0) - || (region->free_list != NULL && region->total_free != 0)); - - /* Link us back into the free node list. */ - node->next = cache->free_node_list; - cache->free_node_list = node->next; - - return ptr; - } - last = &node->next; - node = node->next; - } - } - prev = ®ion->next; - region = region->next; - } - - return NULL; -} - -KeCodeRegion *ke_AddRegionForSize(KeCodeCache *cache, size_t size) -{ - KeCodeRegion *region; - - region = new KeCodeRegion; - - size = ke_GetAllocSize(size); - size += cache->page_granularity * 2; - size -= size % cache->page_granularity; - -#if defined KE_PLATFORM_WINDOWS - region->block_start = (unsigned char *)VirtualAlloc(NULL, size, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE); -#elif defined KE_PLATFORM_POSIX - region->block_start = (unsigned char *)mmap(NULL, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0); - region->block_start = (region->block_start == MAP_FAILED) ? NULL : region->block_start; -#else -#error "TODO" -#endif - - if (region->block_start == NULL) - { - delete region; - return NULL; - } - - region->block_pos = region->block_start; - region->end_free = region->total_free = region->total_size = size; - region->next = cache->first_live; - cache->first_live = region; - region->free_list = NULL; - - return region; -} - -void *Knight::KE_AllocCode(KeCodeCache *cache, size_t size) -{ - void *ptr; - - /* Check live easy-adds */ - if (cache->first_live != NULL) - { - if ((ptr = ke_AllocFromLive(cache, size)) != NULL) - { - return ptr; - } - } - - /* Try looking in the free lists */ - if (cache->first_partial != NULL) - { - if ((ptr = ke_AllocFromPartial(cache, size)) != NULL) - { - return ptr; - } - } - - /* Create a new region */ - if (ke_AddRegionForSize(cache, size) == NULL) - { - return NULL; - } - - return ke_AllocFromLive(cache, size); -} - -KeFreedCode *ke_GetFreeNode(KeCodeCache *cache) -{ - KeFreedCode *ret; - - if (cache->free_node_list != NULL) - { - ret = cache->free_node_list; - cache->free_node_list = ret->next; - - return ret; - } - - /* See if the current free node region has space. */ - if (cache->node_cache != NULL - && cache->node_cache->end_free >= sizeof(KeFreedCode)) - { - ret = (KeFreedCode *)cache->node_cache->block_pos; - cache->node_cache->block_pos += sizeof(KeFreedCode); - cache->node_cache->total_free -= sizeof(KeFreedCode); - cache->node_cache->end_free -= sizeof(KeFreedCode); - - return ret; - } - - /* Otherwise, we need to alloc a new region. */ - KeCodeRegion *region = new KeCodeRegion; - - region->block_start = new unsigned char[cache->page_size / sizeof(KeFreedCode)]; - region->block_pos = region->block_start + sizeof(KeFreedCode); - region->total_size = cache->page_size / sizeof(KeFreedCode); - region->total_free = region->end_free = (region->total_size - sizeof(KeFreedCode)); - region->free_list = NULL; - region->next = cache->node_cache; - cache->node_cache = region; - - return (KeFreedCode *)region->block_start; -} - -void Knight::KE_FreeCode(KeCodeCache *cache, void *code) -{ - KeSecret *secret; - KeFreedCode *node; - unsigned char *ptr; - KeCodeRegion *region; - - ptr = (unsigned char *)code; - secret = (KeSecret *)(ptr - sizeof(KeSecret)); - region = secret->region; - node = ke_GetFreeNode(cache); - node->block_start = (unsigned char *)code; - node->next = region->free_list; - region->free_list = node; - node->region = region; - node->size = secret->size; -} - -KeCodeRegion *ke_DestroyRegion(KeCodeRegion *region) -{ - KeCodeRegion *next; - - next = region->next; - -#if defined KE_PLATFORM_WINDOWS - VirtualFree(region->block_start, 0, MEM_RELEASE); -#else - munmap(region->block_start, region->total_size); -#endif - - delete region; - - return next; -} - -void ke_DestroyRegionChain(KeCodeRegion *first) -{ - while (first != NULL) - { - first = ke_DestroyRegion(first); - } -} - -void Knight::KE_DestroyCodeCache(KeCodeCache *cache) -{ - /* Destroy every region and call it a day. */ - ke_DestroyRegionChain(cache->first_full); - ke_DestroyRegionChain(cache->first_live); - ke_DestroyRegionChain(cache->first_partial); - - /* We use normal malloc for node cache regions */ - KeCodeRegion *region, *next; - - region = cache->node_cache; - while (region != NULL) - { - next = region->next; - delete [] region->block_start; - delete region; - region = next; - } - - delete cache; -} diff --git a/knight/shared/KeCodeAllocator.h b/knight/shared/KeCodeAllocator.h deleted file mode 100644 index cbe21f16..00000000 --- a/knight/shared/KeCodeAllocator.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _INCLUDE_KNIGHT_KE_CODE_ALLOCATOR_H_ -#define _INCLUDE_KNIGHT_KE_CODE_ALLOCATOR_H_ - -#include -#include -#include - -namespace Knight -{ - class KeCodeCache; - - /** - * @brief Creates a new code cache/allocator. - * - * @return New code cache allocator. - */ - extern KeCodeCache *KE_CreateCodeCache(); - - /** - * @brief Destroys a code cache allocator. - * - * @param cache Code cache object. - */ - extern void KE_DestroyCodeCache(KeCodeCache *cache); - - /** - * @brief Allocates code memory that is readable, writable, - * and executable. - * - * The address returned wlil be aligned, minimally, on a 16-byte - * boundary. - * - * @param cache Code cache object. - * @param size Amount of memory needed. - * @return Address pointing to the memory. - */ - extern void *KE_AllocCode(KeCodeCache *cache, size_t size); - - /** - * @brief Frees code memory. - * - * @param cache Code cache object. - * @param code Address of code memory. - */ - extern void KE_FreeCode(KeCodeCache *cache, void *code); -} - -#endif //_INCLUDE_KNIGHT_KE_CODE_ALLOCATOR_H_ diff --git a/knight/shared/KeCommon.cpp b/knight/shared/KeCommon.cpp deleted file mode 100644 index ce23e43b..00000000 --- a/knight/shared/KeCommon.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include "KeCommon.h" - -using namespace Knight; - -size_t Knight::KE_PFormat(char *buffer, size_t maxlength, const char *fmt, ...) -{ - size_t len; - - va_list ap; - va_start(ap, fmt); - len = KE_PFormatArgs(buffer, maxlength, fmt, ap); - va_end(ap); - - return len; -} - -size_t Knight::KE_PFormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list ap) -{ - size_t len; - - len = vsnprintf(buffer, maxlength, fmt, ap); - - if (len >= maxlength) - { - buffer[maxlength - 1] = '\0'; - return (maxlength - 1); - } - else - { - return len; - } -} diff --git a/knight/shared/KeCommon.h b/knight/shared/KeCommon.h deleted file mode 100644 index c76b36a4..00000000 --- a/knight/shared/KeCommon.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _INCLUDE_KNIGHT_KE_COMMON_UTILS_H_ -#define _INCLUDE_KNIGHT_KE_COMMON_UTILS_H_ - -#include -#include - -namespace Knight -{ - /** - * @brief Formats a buffer with C platform rules. - * - * Unlink platform snprintf, this will never return nonsense values like -1. - * - * @param buffer Buffer to store to. - * @param maxlength Maximum length of buffer (including null terminator). - * @param fmt printf() format string. - * @param ... Formatting arguments. - * @return Number of characters written. - */ - extern size_t KE_PFormat(char *buffer, size_t maxlength, const char *fmt, ...); - - /** - * @brief Formats a buffer with C platform rules. - * - * Unlink platform snprintf, this will never return nonsense values like -1. - * - * @param buffer Buffer to store to. - * @param maxlength Maximum length of buffer (including null terminator). - * @param fmt printf() format string. - * @param args Formatting arguments. - * @return Number of characters written. - */ - extern size_t KE_PFormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list args); -} - -#endif //_INCLUDE_KNIGHT_KE_COMMON_UTILS_H_ diff --git a/knight/shared/KeHashTable.cpp b/knight/shared/KeHashTable.cpp deleted file mode 100644 index d601f11d..00000000 --- a/knight/shared/KeHashTable.cpp +++ /dev/null @@ -1,416 +0,0 @@ -#include -#include - -using namespace Knight; - -struct KeHashNode -{ - KeHashNode *next; - uint32_t key_hash; - const void *key; - void *value; -}; - -namespace Knight -{ - class KeHashTable - { - public: - KeHashNode **buckets; - uint32_t num_buckets; - uint32_t shift; - uint32_t num_entries; - KeHashGenerator key_gen; - KeHashMarshal key_m; - KeHashMarshal val_m; - ke_allocator_t *node_alloc; - size_t key_offs; - size_t val_offs; - size_t node_size; - uint32_t grow_limit; - KeHashNode *free_list; - bool keep_free_list; - }; -} - -void *ke_DefHashMalloc(ke_allocator_t *alloc, size_t amt) -{ - return malloc(amt); -} - -void ke_DefHashFree(ke_allocator_t *alloc, void *addr) -{ - free(addr); -} - -ke_allocator_t s_DefHashAllocator = -{ - ke_DefHashMalloc, - ke_DefHashFree, - NULL -}; - -KeHashTable *Knight::KE_CreateHashTable( - uint32_t bits, - KeHashGenerator key_gen, - const KeHashMarshal *key_marshal, - const KeHashMarshal *val_marshal, - ke_allocator_t *nodeAlloc, - bool keep_free_list) -{ - KeHashTable *table; - - if (bits >= 27) - { - bits = 26; - } - else if (bits < 4) - { - bits = 4; - } - - /* Validate marshals. */ - if ((key_marshal->bytes != 0 - && key_marshal->ctor == NULL) - || (val_marshal->bytes != 0 - && val_marshal->ctor == NULL)) - { - return NULL; - } - - table = new KeHashTable; - table->key_gen = key_gen; - table->key_m = *key_marshal; - table->val_m = *val_marshal; - table->num_entries = 0; - table->shift = 32 - bits; - table->node_alloc = nodeAlloc == NULL ? &s_DefHashAllocator : nodeAlloc; - table->num_buckets = (1 << bits); - table->grow_limit = (uint32_t)(0.9f * table->num_buckets); - table->keep_free_list = keep_free_list; - table->free_list = NULL; - table->buckets = (KeHashNode **)malloc(sizeof(KeHashNode *) * table->num_buckets); - memset(table->buckets, 0, sizeof(KeHashNode *) * table->num_buckets); - - table->key_offs = sizeof(KeHashNode); - if (table->key_m.bytes != 0 && table->key_m.bytes % 8 != 0) - { - table->key_m.bytes += 8; - table->key_m.bytes -= (table->key_m.bytes % 8); - } - - table->val_offs = table->key_offs + table->key_m.bytes; - table->node_size = table->val_offs + table->val_m.bytes; - - return table; -} - -#define KE_GET_BUCKET(tbl, hsh) (&(tbl)->buckets[((hsh) * 0x9E3779B9) >> (tbl)->shift]) - -KeHashNode **ke_HashInternalFind(KeHashTable *table, uint32_t key_hash, const void *key) -{ - KeHashNode *node; - KeHashNode **bucket; - - bucket = KE_GET_BUCKET(table, key_hash); - - /* :TODO: move to the front once found? */ - - while ((node = *bucket) != NULL) - { - if (node->key_hash == key_hash - && ((table->key_m.cmp != NULL && table->key_m.cmp(node->key, key)) - || node->key == key)) - { - return bucket; - } - bucket = &node->next; - } - - return bucket; -} - -void ke_ResizeHashTable(KeHashTable *table, uint32_t new_shift) -{ - uint32_t entries; - KeHashNode *next; - KeHashNode *node; - KeHashNode **rbucket; - KeHashNode **old_buckets; - uint32_t old_num_buckets; - - /* Save old data */ - old_num_buckets = table->num_buckets; - old_buckets = table->buckets; - entries = table->num_entries; - - /* Save new data */ - table->num_buckets = (1 << new_shift); - table->shift = 32 - new_shift; - table->grow_limit = (uint32_t)(0.9f * table->num_buckets); - - table->buckets = (KeHashNode **)malloc(sizeof(KeHashNode *) * table->num_buckets); - memset(table->buckets, 0, sizeof(KeHashNode *) * table->num_buckets); - - /* For each old bucket... */ - for (uint32_t i = 0; - i < old_num_buckets && entries != 0; - i++) - { - node = old_buckets[i]; - /* Get each item in its list... */ - while (node != NULL) - { - next = node->next; - - /* Find the new replacement bucket it needs to go in. */ - rbucket = KE_GET_BUCKET(table, node->key_hash); - - /* Link this node to the next node in the new bucket. */ - if (*rbucket == NULL) - { - node->next = NULL; - } - else - { - node->next = *rbucket; - } - - /* Add us to the front of that bucket's list. */ - *rbucket = node; - - node = next; - } - } - - free(old_buckets); -} - -void Knight::KE_AddToHashTable(KeHashTable *table, const void *key, void *val) -{ - KeHashNode *node; - uint32_t key_hash; - KeHashNode **bucket; - - key_hash = table->key_gen(key); - bucket = ke_HashInternalFind(table, key_hash, key); - - if ((node = *bucket) != NULL) - { - /* Already in the table */ - if ((table->val_m.cmp != NULL && table->val_m.cmp(node->value, val)) - || node->value == val) - { - return; - } - - /* Destroy old value if it's set. */ - if (node->value != NULL && table->val_m.dtor != NULL) - { - table->val_m.dtor(node->value); - } - - /* Construct or set the new value. */ - if (table->val_m.bytes != 0) - { - table->val_m.ctor(node->value, val); - } - else - { - node->value = val; - } - - return; - } - - /* If we're overloaded, we may need to resize. - * Right now, we do this if we hit a .9 entry:buckets ratio. - */ - if (table->num_entries >= table->grow_limit) - { - ke_ResizeHashTable(table, table->shift << 1); - bucket = ke_HashInternalFind(table, key_hash, key); - } - - if (table->free_list != NULL) - { - node = table->free_list; - table->free_list = node->next; - } - else - { - node = (KeHashNode *)table->node_alloc->alloc(table->node_alloc, table->node_size); - } - - if (table->key_m.bytes == 0) - { - node->key = key; - } - else - { - node->key = (char *)node + table->key_offs; - table->key_m.ctor((void *)node->key, key); - } - - if (table->val_m.bytes == 0) - { - node->value = val; - } - else - { - node->value = (char *)node + table->val_offs; - table->val_m.ctor(node->value, val); - } - - node->next = *bucket; - node->key_hash = key_hash; - *bucket = node; -} - -inline void ke_CleanUpHashNode(KeHashTable *table, KeHashNode *node) -{ - /* Destroy old value if it's set. */ - if (node->value != NULL && table->val_m.dtor != NULL) - { - table->val_m.dtor(node->value); - } - - /* Destroy the key. */ - if (table->key_m.dtor != NULL) - { - table->key_m.dtor(node->key); - } - - /* Deallocate us as appropriate. */ - if (table->keep_free_list) - { - node->next = table->free_list; - table->free_list = node; - } - else - { - table->node_alloc->dealloc(table->node_alloc, node); - } -} - -void Knight::KE_RemoveFromHashTable(KeHashTable *table, const void *key) -{ - KeHashNode *node; - uint32_t key_hash; - KeHashNode **bucket; - - key_hash = table->key_gen(key); - bucket = ke_HashInternalFind(table, key_hash, key); - - if ((node = *bucket) == NULL) - { - return; - } - - /* Link the bucket to its next (removing us). */ - *bucket = node->next; - - ke_CleanUpHashNode(table, node); -} - -bool Knight::KE_FindInHashTable(KeHashTable *table, const void *key, void **value) -{ - KeHashNode *node; - uint32_t key_hash; - KeHashNode **bucket; - - key_hash = table->key_gen(key); - bucket = ke_HashInternalFind(table, key_hash, key); - - if ((node = *bucket) == NULL) - { - return false; - } - - if (value != NULL) - { - *value = node->value; - } - - return true; -} - -void Knight::KE_DestroyHashTable(KeHashTable *table) -{ - KeHashNode *node, *next; - - /* Turn off this caching! */ - table->keep_free_list = false; - - /* Find entries in buckets that need to be freed. */ - for (uint32_t i = 0; i < table->num_buckets; i++) - { - node = table->buckets[i]; - - while (node != NULL) - { - next = node->next; - ke_CleanUpHashNode(table, node); - node = next; - } - } - - /* Free the free list */ - while (table->free_list != NULL) - { - next = table->free_list->next; - ke_CleanUpHashNode(table, table->free_list); - table->free_list = next; - } - - /* Destroy everything now. */ - free(table->buckets); - delete table; -} - -void Knight::KE_ClearHashTable(KeHashTable *table) -{ - KeHashNode *node, *next; - - /* Free every entry in the table. */ - for (uint32_t i = 0; i < table->num_buckets; i++) - { - node = table->buckets[i]; - - while (node != NULL) - { - next = node->next; - ke_CleanUpHashNode(table, node); - node = next; - } - } -} - -#if defined _MSC_VER && (defined _M_IX86 || defined _M_AMD64 || defined _M_X64) -#pragma intrinsic(_rotl) -#endif - -uint32_t Knight::KE_HashString(const void *str) -{ - uint32_t h; - const unsigned char *us; - - h = 0; - - for (us = (const unsigned char *)str; *us != 0; us++) - { -#if defined _MSC_VER && (defined _M_IX86 || defined _M_AMD64 || defined _M_X64) - h = _rotl(h, 4) ^ *us; -#else - h = ((h << 4) | (h >> 28)) ^ *us; -#endif - } - - return h; -} - -bool Knight::KE_AreStringsEqual(const void* str1, const void* str2) -{ - return (strcmp((const char*)str1, (const char*)str2) == 0) ? true : false; -} - diff --git a/knight/shared/KeHashTable.h b/knight/shared/KeHashTable.h deleted file mode 100644 index cecfd0c6..00000000 --- a/knight/shared/KeHashTable.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef _INCLUDE_KNIGHT_KE_HASHTABLE_H_ -#define _INCLUDE_KNIGHT_KE_HASHTABLE_H_ - -#include -#include -#include - -namespace Knight -{ - class KeHashTable; - - /** - * @brief Must generate a hash function given a key. - * - * @param key Pointer to the key. - * @return Hash value. - */ - typedef uint32_t (*KeHashGenerator)(const void *key); - - /** - * @brief Must compare two values. - * - * @param val1 First value. - * @param val2 Second value. - * @return True if equal, false if not. - */ - typedef bool (*KeHashComparator)(const void *val1, const void *val2); - - /** - * @brief Must call the destructor of the given data, and free if necessary. - * - * @param val Pointer to data. - */ - typedef void (*KeHashDestructor)(const void *val); - - /** - * @brief Must transfer the contents of an object from the source to the destination. - * - * @param dest Destination address. - * @param source Source address. - */ - typedef void (*KeHashCopyCtor)(void *dest, const void *source); - - /** - * @brief Contains information about how to process keys and values in a hash table. - */ - struct KeHashMarshal - { - size_t bytes; /**< Bytes of storage needed (0 to use pointers). */ - KeHashComparator cmp; /**< Comparator (if NULL, void * comparison used) */ - KeHashDestructor dtor; /**< Optional function for performing dtor cleanup. */ - KeHashCopyCtor ctor; /**< If bytes != 0, must be a valid function - (ignored otherwise). */ - }; - - /** - * @brief Creates a new hash table structure. - * - * @param bits Dictates starting number of buckets as a power of two. - * Pass 0 for the default (which is 4). - * @param key_gen Key generation function. - * @param key_marshal Structure detailing how to marshal keys. - * @param vak_marshal Structure detailing how to marshal values. - * @param nodeAlloc Node allocator (can be NULL for malloc/free). - * @param keep_free_list True to keep a free list of nodes, false otherwise. - * @return New hash table container. - */ - extern KeHashTable *KE_CreateHashTable( - uint32_t bits, - KeHashGenerator key_gen, - const KeHashMarshal *key_marshal, - const KeHashMarshal *val_marshal, - ke_allocator_t *nodeAlloc, - bool keep_free_list - ); - - /** - * @brief Destroys a hash table. - * - * @param table Hash table. - */ - extern void KE_DestroyHashTable(KeHashTable *table); - - /** - * @brief Adds a key/value to the hash table. If the pair already exists, the old value - * is overwritten (calling any destructors as necessary). - * - * @param table Hash table. - * @param key Key pointer. - * @param val Value pointer. - */ - extern void KE_AddToHashTable(KeHashTable *table, const void *key, void *val); - - /** - * @brief Removes a key entry from the hash table. - * - * @param table Hash table. - * @param key Key pointer. - */ - extern void KE_RemoveFromHashTable(KeHashTable *table, const void *key); - - /** - * @brief Finds an entry in the hash table. - * - * @param table Hash table. - * @param key Key pointer. - * @param value Pointer to store the value (optional). - * @return On success, true is returned and value is filled if given. - * On failure, false is failed and outputs are undefined. - */ - extern bool KE_FindInHashTable(KeHashTable *table, const void *key, void **value); - - /** - * @brief Clears all entries in the hash table (caching free entries when possible). - * - * @param table Hash table. - */ - extern void KE_ClearHashTable(KeHashTable *table); - - /** - * @brief Generic function for hashing strings. - * - * @param str Key string. - * @return Hash value. - */ - extern uint32_t KE_HashString(const void *str); - - /** - * @brief Generic case-sensitive comparison of strings. - * - * @param str1 First string. - * @param str2 Second string. - * @return True if equal, false otherwise. - */ - extern bool KE_AreStringsEqual(const void* str1, const void* str2); -} - -#endif //_INCLUDE_KNIGHT_KE_HASHTABLE_H_ - diff --git a/knight/shared/KeLinking.h b/knight/shared/KeLinking.h deleted file mode 100644 index 9bb7bb07..00000000 --- a/knight/shared/KeLinking.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _INCLUDE_KNIGHT_LINKING_H_ -#define _INCLUDE_KNIGHT_LINKING_H_ - -#if defined KE_LINK_IMPORT -#error "Not yet supported" -#elif defined KE_LINK_EXPORT -#error "Not yet supported" -#else -#define KE_LINK -#endif - -#endif //_INCLUDE_KNIGHT_LINKING_H_ diff --git a/knight/shared/KeLumpAllocator.cpp b/knight/shared/KeLumpAllocator.cpp deleted file mode 100644 index 151e030e..00000000 --- a/knight/shared/KeLumpAllocator.cpp +++ /dev/null @@ -1,263 +0,0 @@ -#include "KePlatform.h" -#include -#include - -using namespace Knight; - -/** - * :TODO: don't make this part of the page, because touching it means - * dirtying a page. Instead, we should have a separate linked list. - * Maybe that linked list itself could be marshalled from one page. - */ -struct KeLumpRegion -{ - char *base; - char *cur; - size_t size; - size_t avail; - KeLumpRegion *next; - KeLumpRegion *prev; -}; - -class KeLumpAllocator -{ -public: - KeLumpAllocator() : m_pUsableRegions(NULL), m_pUnusableRegions(NULL) - { - m_DefLumpSize = 65536; - -#if defined KE_PLATFORM_WINDOWS - SYSTEM_INFO info; - - GetSystemInfo(&info); - if (info.dwAllocationGranularity > m_DefLumpSize) - { - m_DefLumpSize = info.dwAllocationGranularity; - } -#endif - } - - ~KeLumpAllocator() - { - FreeRegionChain(m_pUsableRegions); - FreeRegionChain(m_pUnusableRegions); - } - - void Reset() - { - KeLumpRegion *region; - - /* Find the tail of the usable regions. */ - region = m_pUsableRegions; - while (region != NULL) - { - if (region->next == NULL) - { - break; - } - } - - /* Link the unusable chain into the usable chain. */ - if (region == NULL) - { - m_pUsableRegions = m_pUnusableRegions; - } - else - { - region->next = m_pUnusableRegions; - m_pUnusableRegions->prev = region; - } - m_pUnusableRegions = NULL; - - region = m_pUsableRegions; - while (region != NULL) - { - region->avail = region->size; - region->cur = region->base; - region = region->next; - } - } - - void FreeRegionChain(KeLumpRegion *region) - { - KeLumpRegion *next; - - while (region != NULL) - { - next = region->next; - -#if defined KE_PLATFORM_WINDOWS - VirtualFree(region, 0, MEM_RELEASE); -#else - free(region); -#endif - region = next; - } - } - - void *Alloc(size_t size) - { - char *blob; - KeLumpRegion *region; - - if (size % 8 != 0) - { - size += 8; - size -= size % 8; - } - - region = FindRegionForSize(size); - - blob = region->cur; - region->avail -= size; - region->cur += size; - - /** - * Technically we could make one last small allocation, but - * this edge case is not worth the extra work. - */ - if (region->avail < 8) - { - /* Unlink us from the usable list */ - if (region == m_pUsableRegions) - { - m_pUsableRegions = m_pUsableRegions->next; - m_pUsableRegions->prev = NULL; - } - else - { - region->prev->next = region->next; - if (region->next != NULL) - { - region->next->prev = region->prev; - } - } - - /* Link us into the unusable list */ - region->prev = NULL; - region->next = m_pUnusableRegions; - - if (m_pUnusableRegions != NULL) - { - m_pUnusableRegions->prev = region; - } - - m_pUnusableRegions = region; - } - - return blob; - } - -private: - KeLumpRegion *FindRegionForSize(size_t size) - { - char *base; - KeLumpRegion *region; - size_t size_of_region; - - /** - * :TODO: replace this with a priority queue or something - * that's actually fast. Even worse is we dirty pages by - * doing this. Ouch! - */ - region = m_pUsableRegions; - while (region != NULL) - { - if (region->avail >= size) - { - return region; - } - region = region->next; - } - - /* Make sure regions end at 8-byte alignment. */ - size_of_region = sizeof(KeLumpRegion); - if (size_of_region % 8 != 0) - { - size_of_region += 8; - size_of_region -= size_of_region % 8; - } - - /* If the size is too big, fix that. */ - if (size > m_DefLumpSize - size_of_region) - { - size += m_DefLumpSize; - size -= size % m_DefLumpSize; - } - else - { - size = m_DefLumpSize; - } - -#if defined KE_PLATFORM_WINDOWS - base = (char *)VirtualAlloc( - NULL, - m_DefLumpSize, - MEM_COMMIT|MEM_RESERVE, - PAGE_READWRITE); -#else - base = (char*)valloc(m_DefLumpSize); -#endif - - /* Initialize the region */ - region = (KeLumpRegion *)base; - region->base = &base[size_of_region]; - region->size = size - size_of_region; - region->cur = region->base; - region->avail = region->size; - region->prev = NULL; - region->next = m_pUsableRegions; - - if (m_pUsableRegions != NULL) - { - m_pUsableRegions->prev = region; - } - - m_pUsableRegions = region; - - return region; - } - -private: - KeLumpRegion *m_pUsableRegions; - KeLumpRegion *m_pUnusableRegions; - size_t m_DefLumpSize; -}; - -inline KeLumpAllocator *ke_LumpFromAllocator(ke_allocator_t *arena) -{ - return (KeLumpAllocator *)arena->user; -} - -void *ke_LumpAlloc(ke_allocator_t *arena, size_t size) -{ - return ke_LumpFromAllocator(arena)->Alloc(size); -} - -void ke_LumpFree(ke_allocator_t *arena, void *ptr) -{ -} - -ke_allocator_t * KE_LINK Knight::KE_CreateLumpAllocator() -{ - ke_allocator_t *alloc; - - alloc = new ke_allocator_t; - alloc->alloc = ke_LumpAlloc; - alloc->dealloc = ke_LumpFree; - alloc->user = new KeLumpAllocator(); - - return alloc; -} - -void KE_LINK Knight::KE_DestroyLumpAllocator(ke_allocator_t *alloc) -{ - delete ke_LumpFromAllocator(alloc); - delete alloc; -} - -void KE_LINK Knight::KE_ResetLumpAllocator(ke_allocator_t *alloc) -{ - ke_LumpFromAllocator(alloc)->Reset(); -} - diff --git a/knight/shared/KeLumpAllocator.h b/knight/shared/KeLumpAllocator.h deleted file mode 100644 index 96660dc7..00000000 --- a/knight/shared/KeLumpAllocator.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _INCLUDE_KNIGHT_KE_LUMP_ALLOCATOR_H_ -#define _INCLUDE_KNIGHT_KE_LUMP_ALLOCATOR_H_ - -#include -#include - -namespace Knight -{ - /** - * @brief Creates a new lump allocator. - * - * The lump allocator is intended for cases where there are many allocations - * and none need to be freed. There is memory wastage, and the lump allocator - * is typically thrown away after use. - * - * @return New lump allocator. - */ - extern ke_allocator_t * KE_CreateLumpAllocator(); - - /** - * @brief Destroys a lump allocator, freeing all of its resources. - * - * @param lump Lump allocator. - */ - extern void KE_DestroyLumpAllocator(ke_allocator_t *alloc); - - /** - * @brief Clears a lump allocator, so its memory can be re-used from - * the start. - * - * @param lump Lump allocator. - */ - extern void KE_ResetLumpAllocator(ke_allocator_t *alloc); -} - -#endif //_INCLUDE_KNIGHT_KE_LUMP_ALLOCATOR_H_ diff --git a/knight/shared/KePageAllocator.cpp b/knight/shared/KePageAllocator.cpp deleted file mode 100644 index 71d62a22..00000000 --- a/knight/shared/KePageAllocator.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#include "KePageAllocator.h" - -using namespace Knight; - -struct PageInfo -{ - PageInfo *next; - void *base; -}; - -class Knight::KePageAllocator -{ -public: - size_t page_size; - size_t page_granularity; - PageInfo *free_pages; - PageInfo *page_blocks; -}; - -static void *ke_LumpPageAlloc(KePageAllocator *alloc) -{ - void *base; - char *page; - PageInfo *lump; - size_t pagesInBlock; - -#if defined KE_PLATFORM_WINDOWS - base = VirtualAlloc( - NULL, - alloc->page_granularity, - MEM_COMMIT|MEM_RESERVE, - PAGE_READWRITE); -#elif defined KE_PLATFORM_POSIX - base = valloc(alloc->page_granularity); -#else -#error "Unsupported platform" -#endif - - if (base == NULL) - { - return NULL; - } - - lump = new PageInfo; - lump->base = base; - lump->next = alloc->page_blocks; - alloc->page_blocks = lump->next; - - page = (char *)base + alloc->page_size; - pagesInBlock = alloc->page_granularity / alloc->page_size; - - for (size_t i = 1; i < pagesInBlock; i++) - { - lump = new PageInfo; - lump->base = page; - lump->next = alloc->free_pages; - alloc->free_pages = lump; - page += alloc->page_size; - } - - return base; -} - -KePageAllocator *Knight::KE_CreatePageAllocator() -{ - KePageAllocator *alloc; - - alloc = new KePageAllocator; - -#if defined KE_PLATFORM_WINDOWS - SYSTEM_INFO info; - - GetSystemInfo(&info); - alloc->page_size = info.dwPageSize; - alloc->page_granularity = info.dwAllocationGranularity; -#elif defined KE_PLATFORM_POSIX - alloc->page_size = sysconf(_SC_PAGESIZE); - alloc->page_granularity = alloc->page_size * 16; -#else -#error "Unsupported platform" -#endif - - alloc->free_pages = NULL; - alloc->page_blocks = NULL; - - return alloc; -} - -void Knight::KE_DestroyPageAllocator(KePageAllocator *alloc) -{ - PageInfo *info, *next; - - info = alloc->page_blocks; - while (info != NULL) - { - next = info->next; -#if defined KE_PLATFORM_WINDOWS - VirtualFree(info->base, 0, MEM_RELEASE); -#elif defined KE_PLATFORM_WINDOWS - free(info->base); -#else -#error "Unsupported platform" -#endif - delete info; - next = info; - } - - info = alloc->free_pages; - while (info != NULL) - { - next = info->next; - delete info; - info = next; - } -} - -void *Knight::KE_PageAlloc(KePageAllocator *alloc) -{ - if (alloc->free_pages != NULL) - { - void *base; - PageInfo *info; - - info = alloc->free_pages; - alloc->free_pages = info->next; - base = info->base; - delete info; - - return base; - } - - return ke_LumpPageAlloc(alloc); -} - -void Knight::KE_PageFree(KePageAllocator *alloc, void *page) -{ - PageInfo *info; - - info = new PageInfo; - info->base = page; - info->next = alloc->free_pages; - alloc->free_pages = info->next; -} - -size_t Knight::KE_PageSize(KePageAllocator *alloc) -{ - return alloc->page_size; -} diff --git a/knight/shared/KePageAllocator.h b/knight/shared/KePageAllocator.h deleted file mode 100644 index 6ac1f702..00000000 --- a/knight/shared/KePageAllocator.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _INCLUDE_KNIGHT_KE_PAGE_ALLOCATOR_H_ -#define _INCLUDE_KNIGHT_KE_PAGE_ALLOCATOR_H_ - -#include -#include - -namespace Knight -{ - class KePageAllocator; - - /** - * @brief Creates a page allocator. - * - * @return New page allocator. - */ - extern KePageAllocator *KE_CreatePageAllocator(); - - /** - * @brief Destroys a page allocator, freeing all live pages it owns. - * - * @param Page allocator. - */ - extern void KE_DestroyPageAllocator(KePageAllocator *alloc); - - /** - * @brief Allocates a page of memory. - * - * @param alloc Page allocator. - * @return Page of memory. - */ - extern void *KE_PageAlloc(KePageAllocator *alloc); - - /** - * @brief Frees a page of memory. - * - * @param alloc Page allocator. - * @param page Page of memory. - */ - extern void KE_PageFree(KePageAllocator *alloc, void *page); - - /** - * @brief Returns the size of a page. - * - * @param alloc Page allocator. - * @return Page size. - */ - extern size_t KE_PageSize(KePageAllocator *alloc); -} - -#endif //_INCLUDE_KNIGHT_KE_PAGE_ALLOCATOR_H_ diff --git a/knight/shared/KePlatform.h b/knight/shared/KePlatform.h deleted file mode 100644 index 220a1bfc..00000000 --- a/knight/shared/KePlatform.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _INCLUDE_KNIGHT_KE_PLATFORM_H_ -#define _INCLUDE_KNIGHT_KE_PLATFORM_H_ - -#if defined WIN32 - -#define KE_PLATFORM_WINDOWS -#define WINDOWS_LEAN_AND_MEAN -#include -#include - -#if !defined alloca -#define alloca _alloca -#endif - -#else - -#define KE_PLATFORM_POSIX - -#if defined __linux__ -#define KE_PLATFORM_LINUX -#elif defined __APPLE__ -#define KE_PLATFORM_APPLE -#else -#error "TODO" -#endif - -#endif - -#endif //_INCLUDE_KNIGHT_KE_PLATFORM_H_ diff --git a/knight/shared/KeSectorStack.h b/knight/shared/KeSectorStack.h deleted file mode 100644 index c18be942..00000000 --- a/knight/shared/KeSectorStack.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef _INCLUDE_KNIGHT_KE_SECTOR_STACK_H_ -#define _INCLUDE_KNIGHT_KE_SECTOR_STACK_H_ - -#include -#include - -namespace Knight -{ - template - class KeSectorStack - { - public: - static const size_t DEFAULT_SECTOR_SIZE = 64; - - KeSectorStack() : m_SectorSize(DEFAULT_SECTOR_SIZE), m_UsedSize(0), m_MaxUsedSize(0) - { - m_pAlloc = NULL; - } - - KeSectorStack(size_t sectorSize) : m_SectorSize(sectorSize), m_UsedSize(0), m_MaxUsedSize(0) - { - m_pAlloc = NULL; - } - - KeSectorStack(size_t sectorSize, ke_allocator_t *alloc) : - m_SectorSize(sectorSize), m_UsedSize(0), m_pAlloc(alloc), m_MaxUsedSize(0) - { - } - - ~KeSectorStack() - { - clear(); - } - - void clear() - { - T *sector; - size_t last_sector; - size_t last_sector_item; - - if (m_MaxUsedSize == 0) - { - return; - } - - last_sector = (m_MaxUsedSize - 1) / m_SectorSize; - last_sector_item = (m_MaxUsedSize - 1) % m_SectorSize; - - for (size_t i = 0; i < last_sector; i++) - { - sector = m_Sectors[i]; - - for (size_t j = 0; j < m_SectorSize; j++) - { - sector[j].~T(); - } - } - - sector = m_Sectors[last_sector]; - for (size_t i = 0; i <= last_sector_item; i++) - { - sector[i].~T(); - } - - clear_no_dtors(); - } - - void clear_no_dtors() - { - for (size_t i = 0; i < m_Sectors.size(); i++) - { - free_sector(m_Sectors[i]); - } - - m_Sectors.clear(); - } - - bool empty() - { - return (m_UsedSize == 0) ? true : false; - } - - void push(const T & val) - { - if ((m_UsedSize / m_SectorSize) >= m_Sectors.size()) - { - /* Create a new sector */ - T * sector; - - if (m_pAlloc == NULL) - { - sector = (T *)malloc(sizeof(T) * m_SectorSize); - } - else - { - sector = (T *)m_pAlloc->alloc(m_pAlloc, sizeof(T) * m_SectorSize); - } - - m_Sectors.push_back(sector); - } - - at(m_UsedSize) = val; - - m_UsedSize++; - - /* Keep track of the maximum used size so we can defer the - * massive destruction job until the end. - */ - if (m_UsedSize > m_MaxUsedSize) - { - m_MaxUsedSize = m_UsedSize; - } - } - - void pop() - { - m_UsedSize--; - } - - void pop_all() - { - m_UsedSize = 0; - } - - T & front() - { - return at(m_UsedSize - 1); - } - - size_t size() - { - return m_UsedSize; - } - - private: - T & at(size_t x) - { - return m_Sectors[x / m_SectorSize][x % m_SectorSize]; - } - - void free_sector(T * sector) - { - if (m_pAlloc == NULL) - { - free(sector); - } - else if (m_pAlloc->dealloc != NULL) - { - m_pAlloc->dealloc(m_pAlloc, sector); - } - } - - private: - KeVector m_Sectors; - size_t m_SectorSize; - size_t m_UsedSize; - ke_allocator_t *m_pAlloc; - size_t m_MaxUsedSize; - }; -} - -#endif //_INCLUDE_KNIGHT_KE_SECTOR_STACK_H_ diff --git a/knight/shared/KeVector.h b/knight/shared/KeVector.h deleted file mode 100644 index 3564c156..00000000 --- a/knight/shared/KeVector.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef _INCLUDE_KNIGHT_KE_VECTOR_H_ -#define _INCLUDE_KNIGHT_KE_VECTOR_H_ - -#include - -namespace Knight -{ - template - class KeVector - { - public: - KeVector() : m_Data(NULL), m_Size(0), m_CurrentUsedSize(0) - { - } - - KeVector(const KeVector & other) - { - m_Size = other.m_CurrentUsedSize; - m_CurrentUsedSize = other.m_CurrentUsedSize; - - if (m_Size > 0) - { - m_Data = new T[other.m_CurrentUsedSize]; - - for (size_t i = 0; i < m_Size; i++) - { - m_Data[i] = other.m_Data[i]; - } - } - else - { - m_Data = NULL; - } - } - - ~KeVector() - { - clear(); - } - - KeVector & operator =(const KeVector & other) - { - clear(); - - if (other.m_CurrentUsedSize) - { - m_Data = new T[other.m_CurrentUsedSize]; - m_Size = other.m_CurrentUsedSize; - m_CurrentUsedSize = other.m_CurrentUsedSize; - - for (size_t i = 0; i < m_Size; i++) - { - m_Data[i] = other.m_Data[i]; - } - } - } - - size_t size() const - { - return m_CurrentUsedSize; - } - - void push_back(const T & elem) - { - GrowIfNeeded(1); - - new (&m_Data[m_CurrentUsedSize]) T(elem); - - m_CurrentUsedSize++; - } - - void pop_back(const T & elem) - { - if (m_CurrentUsedSize == 0) - { - return; - } - - m_CurrentUsedSize--; - m_Data[m_CurrentUsedSize].~T(); - } - - bool is_empty() - { - return (m_CurrentUsedSize == 0); - } - - T & operator [](size_t pos) - { - return m_Data[pos]; - } - - const T & operator [](size_t pos) const - { - return m_Data[pos]; - } - - void clear() - { - for (size_t i = 0; i < m_CurrentUsedSize; i++) - { - m_Data[i].~T(); - } - - free(m_Data); - - m_Data = NULL; - m_Size = 0; - m_CurrentUsedSize = 0; - } - private: - void Grow(size_t amount) - { - T *new_data; - size_t new_size; - - if (m_Size == 0) - { - new_size = 8; - } - else - { - new_size = m_Size * 2; - } - - while (m_CurrentUsedSize + amount > new_size) - { - new_size *= 2; - } - - new_data = (T *)malloc(sizeof(T) * new_size); - - for (size_t i = 0; i < m_CurrentUsedSize; i++) - { - new (&new_data[i]) T(m_Data[i]); - m_Data[i].~T(); - } - - free(m_Data); - m_Data = new_data; - m_Size = new_size; - } - - void GrowIfNeeded(size_t amount) - { - if (m_CurrentUsedSize + amount >= m_Size) - { - Grow(amount); - } - } - private: - T *m_Data; - size_t m_Size; - size_t m_CurrentUsedSize; - }; -} - -#endif //_INCLUDE_KNIGHT_KE_VECTOR_H_ diff --git a/knight/shared/KnightAllocator.h b/knight/shared/KnightAllocator.h deleted file mode 100644 index 9dacf582..00000000 --- a/knight/shared/KnightAllocator.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _INCLUDE_KNIGHT_ALLOCATOR_H_ -#define _INCLUDE_KNIGHT_ALLOCATOR_H_ - -#include -#include - -struct ke_allocator_s; -typedef struct ke_allocator_s ke_allocator_t; - -typedef void *(*KEFN_ALLOCATOR)(ke_allocator_t *, size_t); -typedef void (*KEFN_DEALLOCATOR)(ke_allocator_t *, void *); - -struct ke_allocator_s -{ - KEFN_ALLOCATOR alloc; - KEFN_DEALLOCATOR dealloc; - void *user; -}; - -inline void *operator new(size_t size, ke_allocator_t *alloc) -{ - return alloc->alloc(alloc, size); -} - -inline void *operator new [](size_t size, ke_allocator_t *alloc) -{ - return alloc->alloc(alloc, size); -} - -template -void ke_destroy(ke_allocator_t *alloc, T * data) -{ - data->~T(); - alloc->dealloc(alloc, data); -} - -#endif //_INCLUDE_KNIGHT_ALLOCATOR_H_ diff --git a/loader/Makefile b/loader/Makefile deleted file mode 100644 index 075ba76c..00000000 --- a/loader/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -MMSOURCE17 = ../../mmsource-central - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = sourcemod_mm - -OBJECTS = loader.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -LINK = -m32 -ldl -lm - -INCLUDE = -I$(MMSOURCE17)/core -I$(MMSOURCE17)/core/sourcehook - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Wno-uninitialized \ - -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT)_i486.so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: - mkdir -p $(BIN_DIR) - $(MAKE) -f Makefile loader - -loader: $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/loader/loader.cpp b/loader/loader.cpp index eb2c8fad..66531929 100644 --- a/loader/loader.cpp +++ b/loader/loader.cpp @@ -87,6 +87,7 @@ #define FILENAME_1_6_BLADE "sourcemod.2.blade" PLATFORM_EXT #define FILENAME_1_6_INSURGENCY "sourcemod.2.insurgency" PLATFORM_EXT #define FILENAME_1_6_CONTAGION "sourcemod.2.contagion" PLATFORM_EXT +#define FILENAME_1_6_BMS "sourcemod.2.bms" PLATFORM_EXT HINSTANCE g_hCore = NULL; bool load_attempted = false; @@ -311,6 +312,11 @@ DLL_EXPORT METAMOD_PLUGIN *CreateInterface_MMS(const MetamodVersionInfo *mvi, co filename = FILENAME_1_6_SDK2013; break; } + case SOURCE_ENGINE_BMS: + { + filename = FILENAME_1_6_BMS; + break; + } case SOURCE_ENGINE_TF2: { filename = FILENAME_1_6_TF2; diff --git a/loader/msvc10/loader.sln b/loader/msvc10/loader.sln deleted file mode 100644 index 3f9dc336..00000000 --- a/loader/msvc10/loader.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loader", "loader.vcxproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/loader/msvc10/loader.vcxproj b/loader/msvc10/loader.vcxproj deleted file mode 100644 index 839d18d5..00000000 --- a/loader/msvc10/loader.vcxproj +++ /dev/null @@ -1,126 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9D161017-A713-44A4-927F-E99097A3FC8D} - loader - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - sourcemod_mm - - - sourcemod_mm - - - - Disabled - ..;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;LOADER_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - ..\..\public;%(AdditionalIncludeDirectories) - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - Speed - ..;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LOADER_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - ..\..\public;%(AdditionalIncludeDirectories) - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - - - - - - - - - - \ No newline at end of file diff --git a/loader/msvc10/loader.vcxproj.filters b/loader/msvc10/loader.vcxproj.filters deleted file mode 100644 index 2bc5a480..00000000 --- a/loader/msvc10/loader.vcxproj.filters +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/loader/msvc8/loader.sln b/loader/msvc8/loader.sln deleted file mode 100644 index 9ead7bea..00000000 --- a/loader/msvc8/loader.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loader", "loader.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/loader/msvc8/loader.vcproj b/loader/msvc8/loader.vcproj deleted file mode 100644 index 8810a871..00000000 --- a/loader/msvc8/loader.vcproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/loader/msvc9/loader.sln b/loader/msvc9/loader.sln deleted file mode 100644 index 3fc60796..00000000 --- a/loader/msvc9/loader.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loader", "loader.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/loader/msvc9/loader.vcproj b/loader/msvc9/loader.vcproj deleted file mode 100644 index b064275e..00000000 --- a/loader/msvc9/loader.vcproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/msvc10/SourceMod.sln b/msvc10/SourceMod.sln deleted file mode 100644 index 6f2df763..00000000 --- a/msvc10/SourceMod.sln +++ /dev/null @@ -1,1052 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sourcemod_mm", "..\core\msvc10\sourcemod_mm.vcxproj", "{E39527CD-7CAB-4420-97CC-DA1B93B260BC}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logic", "..\core\logic\msvc10\logic.vcxproj", "{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{5F822FBB-6A18-4B35-8705-0D5CC734C08A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clientprefs", "..\extensions\clientprefs\msvc10\clientprefs.vcxproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdktools", "..\extensions\sdktools\msvc10\sdktools.vcxproj", "{7A740927-C751-4312-BF9D-6367F8C508F8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bintools", "..\extensions\bintools\msvc10\bintools.vcxproj", "{E38F65D9-74B2-4373-B46A-DBB76F579F98}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tf2", "..\extensions\tf2\msvc10\tf2.vcxproj", "{B3E8AF22-5436-49A4-9A3F-631519874372}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cstrike", "..\extensions\cstrike\msvc10\cstrike.vcxproj", "{18B5ED38-DBB7-47B2-8500-5648B8C1263B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jit-x86", "..\sourcepawn\jit\msvc10\jit-x86.vcxproj", "{307D9D61-51CA-4392-B111-4A3B4229100C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loader", "..\loader\msvc10\loader.vcxproj", "{9D161017-A713-44A4-927F-E99097A3FC8D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "topmenus", "..\extensions\topmenus\msvc10\topmenus.vcxproj", "{C701A837-4258-45D1-93EF-85EDBA7D924A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite", "..\extensions\sqlite\msvc10\sm_sqlite.vcxproj", "{B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdkhooks", "..\extensions\sdkhooks\msvc10\sdkhooks.vcxproj", "{F35CF30D-5C8E-4A95-9F8C-E5A80A124432}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "regex", "..\extensions\regex\msvc10\regex.vcxproj", "{3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - CrazyDebug - Alien Swarm|Win32 = CrazyDebug - Alien Swarm|Win32 - CrazyDebug - Bloody Good Time|Win32 = CrazyDebug - Bloody Good Time|Win32 - CrazyDebug - CS GO|Win32 = CrazyDebug - CS GO|Win32 - CrazyDebug - CSS|Win32 = CrazyDebug - CSS|Win32 - CrazyDebug - Dark Messiah|Win32 = CrazyDebug - Dark Messiah|Win32 - CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|Win32 - CrazyDebug - EYE|Win32 = CrazyDebug - EYE|Win32 - CrazyDebug - Left 4 Dead 2|Win32 = CrazyDebug - Left 4 Dead 2|Win32 - CrazyDebug - Left 4 Dead|Win32 = CrazyDebug - Left 4 Dead|Win32 - CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32 - CrazyDebug - Orange Box Valve|Win32 = CrazyDebug - Orange Box Valve|Win32 - CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32 - Debug - Alien Swarm|Win32 = Debug - Alien Swarm|Win32 - Debug - Bloody Good Time|Win32 = Debug - Bloody Good Time|Win32 - Debug - CS GO|Win32 = Debug - CS GO|Win32 - Debug - CSS|Win32 = Debug - CSS|Win32 - Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - EYE|Win32 = Debug - EYE|Win32 - Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 - Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 - Debug|Win32 = Debug|Win32 - Release - Alien Swarm|Win32 = Release - Alien Swarm|Win32 - Release - Bloody Good Time|Win32 = Release - Bloody Good Time|Win32 - Release - CS GO|Win32 = Release - CS GO|Win32 - Release - CSS|Win32 = Release - CSS|Win32 - Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - EYE|Win32 = Release - EYE|Win32 - Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 - Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = CrazyDebug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Alien Swarm|Win32.Build.0 = CrazyDebug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = CrazyDebug - Bloody Good Time|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Bloody Good Time|Win32.Build.0 = CrazyDebug - Bloody Good Time|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - CS GO|Win32.ActiveCfg = CrazyDebug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - CS GO|Win32.Build.0 = CrazyDebug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - CSS|Win32.ActiveCfg = CrazyDebug - CSS|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - CSS|Win32.Build.0 = CrazyDebug - CSS|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = CrazyDebug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.Build.0 = CrazyDebug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.ActiveCfg = CrazyDebug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.Build.0 = CrazyDebug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - EYE|Win32.ActiveCfg = CrazyDebug - EYE|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - EYE|Win32.Build.0 = CrazyDebug - EYE|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = CrazyDebug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = CrazyDebug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = CrazyDebug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.Build.0 = CrazyDebug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.ActiveCfg = CrazyDebug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.Build.0 = CrazyDebug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = CrazyDebug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.Build.0 = CrazyDebug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.ActiveCfg = CrazyDebug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.Build.0 = CrazyDebug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Alien Swarm|Win32.Build.0 = Debug - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug - Bloody Good Time|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Bloody Good Time|Win32.Build.0 = Debug - Bloody Good Time|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - CSS|Win32.ActiveCfg = Debug - CSS|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - CSS|Win32.Build.0 = Debug - CSS|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - EYE|Win32.ActiveCfg = Debug - EYE|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - EYE|Win32.Build.0 = Debug - EYE|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug|Win32.ActiveCfg = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug|Win32.Build.0 = Debug - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Alien Swarm|Win32.ActiveCfg = Release - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Alien Swarm|Win32.Build.0 = Release - Alien Swarm|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Bloody Good Time|Win32.ActiveCfg = Release - Bloody Good Time|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Bloody Good Time|Win32.Build.0 = Release - Bloody Good Time|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - CSS|Win32.ActiveCfg = Release - CSS|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - CSS|Win32.Build.0 = Release - CSS|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - EYE|Win32.ActiveCfg = Release - EYE|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - EYE|Win32.Build.0 = Release - EYE|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release|Win32.ActiveCfg = Release - Orange Box|Win32 - {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release|Win32.Build.0 = Release - Orange Box|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - CS GO|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - CSS|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - CSS|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Episode 1|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - EYE|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - EYE|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Old Metamod|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.CrazyDebug - Orange Box|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - CS GO|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - CS GO|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - CSS|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - CSS|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Episode 1|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - EYE|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - EYE|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Old Metamod|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug - Orange Box|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Alien Swarm|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Alien Swarm|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Bloody Good Time|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Bloody Good Time|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - CS GO|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - CS GO|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - CSS|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - CSS|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Dark Messiah|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Dark Messiah|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Episode 1|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Episode 1|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - EYE|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - EYE|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Left 4 Dead 2|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Left 4 Dead|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Left 4 Dead|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Old Metamod|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Old Metamod|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Orange Box Valve|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Orange Box Valve|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Orange Box|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release - Orange Box|Win32.Build.0 = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - CS GO|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - CSS|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - CSS|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Episode 1|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - EYE|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - EYE|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Old Metamod|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.CrazyDebug - Orange Box|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - CS GO|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - CS GO|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - CSS|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - CSS|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - EYE|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - EYE|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Alien Swarm|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Alien Swarm|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Bloody Good Time|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Bloody Good Time|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CS GO|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CS GO|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CSS|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CSS|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Dark Messiah|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Dark Messiah|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - EYE|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - EYE|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead 2|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box Valve|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box Valve|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.Build.0 = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Alien Swarm|Win32.Build.0 = Debug - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Bloody Good Time|Win32.Build.0 = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - CSS|Win32.ActiveCfg = Debug - CSS|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - CSS|Win32.Build.0 = Debug - CSS|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - EYE|Win32.ActiveCfg = Debug - EYE|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - EYE|Win32.Build.0 = Debug - EYE|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.CrazyDebug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Alien Swarm|Win32.Build.0 = Debug - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Bloody Good Time|Win32.Build.0 = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - CSS|Win32.ActiveCfg = Debug - CSS|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - CSS|Win32.Build.0 = Debug - CSS|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - EYE|Win32.ActiveCfg = Debug - EYE|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - EYE|Win32.Build.0 = Debug - EYE|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug|Win32.ActiveCfg = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug|Win32.Build.0 = Debug - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Alien Swarm|Win32.ActiveCfg = Release - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Alien Swarm|Win32.Build.0 = Release - Swarm|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Bloody Good Time|Win32.ActiveCfg = Release - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Bloody Good Time|Win32.Build.0 = Release - Bloody Good Time|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - CSS|Win32.ActiveCfg = Release - CSS|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - CSS|Win32.Build.0 = Release - CSS|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - EYE|Win32.ActiveCfg = Release - EYE|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - EYE|Win32.Build.0 = Release - EYE|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release|Win32.ActiveCfg = Release - Orange Box|Win32 - {7A740927-C751-4312-BF9D-6367F8C508F8}.Release|Win32.Build.0 = Release - Orange Box|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - CS GO|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - CSS|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - CSS|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Episode 1|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - EYE|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - EYE|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Old Metamod|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.CrazyDebug - Orange Box|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - CS GO|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - CS GO|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - CSS|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - CSS|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Episode 1|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - EYE|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - EYE|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Old Metamod|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug - Orange Box|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug|Win32.ActiveCfg = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug|Win32.Build.0 = Debug|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Alien Swarm|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Alien Swarm|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Bloody Good Time|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Bloody Good Time|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - CS GO|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - CS GO|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - CSS|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - CSS|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Dark Messiah|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Dark Messiah|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Episode 1|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Episode 1|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - EYE|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - EYE|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead 2|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Left 4 Dead|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Old Metamod|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Old Metamod|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box Valve|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box Valve|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release - Orange Box|Win32.Build.0 = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release|Win32.ActiveCfg = Release|Win32 - {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release|Win32.Build.0 = Release|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - CSS|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - EYE|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - CS GO|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - CSS|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - Episode 1|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - EYE|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Debug|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - Alien Swarm|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - Bloody Good Time|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - CS GO|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - CSS|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - Dark Messiah|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - Episode 1|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - EYE|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - Old Metamod|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E8AF22-5436-49A4-9A3F-631519874372}.Release|Win32.Build.0 = Release - Orange Box Valve|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - CSS|Win32.ActiveCfg = Debug - CSS|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - CSS|Win32.Build.0 = Debug - CSS|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - Episode 1|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - EYE|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - CSS|Win32.ActiveCfg = Debug - CSS|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - CSS|Win32.Build.0 = Debug - CSS|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode1|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - EYE|Win32.ActiveCfg = Debug - Episode1|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Debug|Win32.Build.0 = Debug - Old Metamod|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - Alien Swarm|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - Bloody Good Time|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - CSS|Win32.ActiveCfg = Release - CSS|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - CSS|Win32.Build.0 = Release - CSS|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - Dark Messiah|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - EYE|Win32.ActiveCfg = Release - Episode 1|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release|Win32.ActiveCfg = Release - Orange Box|Win32 - {18B5ED38-DBB7-47B2-8500-5648B8C1263B}.Release|Win32.Build.0 = Release - Orange Box|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - CS GO|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - CSS|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - CSS|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Episode 1|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - EYE|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - EYE|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Old Metamod|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.CrazyDebug - Orange Box|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - CS GO|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - CS GO|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - CSS|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - CSS|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Episode 1|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - EYE|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - EYE|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Old Metamod|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug - Orange Box|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug|Win32.ActiveCfg = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Debug|Win32.Build.0 = Debug|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Alien Swarm|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Alien Swarm|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Bloody Good Time|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Bloody Good Time|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - CS GO|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - CS GO|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - CSS|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - CSS|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Dark Messiah|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Dark Messiah|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Episode 1|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Episode 1|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - EYE|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - EYE|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Left 4 Dead 2|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Left 4 Dead|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Left 4 Dead|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Old Metamod|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Old Metamod|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Orange Box Valve|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Orange Box Valve|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Orange Box|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release - Orange Box|Win32.Build.0 = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release|Win32.ActiveCfg = Release|Win32 - {307D9D61-51CA-4392-B111-4A3B4229100C}.Release|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - CS GO|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - CSS|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - CSS|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Episode 1|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - EYE|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - EYE|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Old Metamod|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.CrazyDebug - Orange Box|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - CS GO|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - CS GO|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - CSS|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - CSS|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Episode 1|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - EYE|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - EYE|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Old Metamod|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug - Orange Box|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug|Win32.ActiveCfg = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Debug|Win32.Build.0 = Debug|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Alien Swarm|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Alien Swarm|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Bloody Good Time|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Bloody Good Time|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - CS GO|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - CS GO|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - CSS|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - CSS|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Dark Messiah|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Dark Messiah|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Episode 1|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Episode 1|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - EYE|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - EYE|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Left 4 Dead 2|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Left 4 Dead|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Left 4 Dead|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Old Metamod|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Old Metamod|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Orange Box Valve|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Orange Box Valve|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Orange Box|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release - Orange Box|Win32.Build.0 = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release|Win32.ActiveCfg = Release|Win32 - {9D161017-A713-44A4-927F-E99097A3FC8D}.Release|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - CS GO|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - CSS|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - CSS|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Episode 1|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - EYE|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - EYE|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Old Metamod|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.CrazyDebug - Orange Box|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - CS GO|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - CS GO|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - CSS|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - CSS|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Episode 1|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - EYE|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - EYE|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Old Metamod|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug - Orange Box|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Debug|Win32.Build.0 = Debug|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Alien Swarm|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Alien Swarm|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Bloody Good Time|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Bloody Good Time|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - CS GO|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - CS GO|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - CSS|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - CSS|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Dark Messiah|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Dark Messiah|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Episode 1|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Episode 1|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - EYE|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - EYE|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Left 4 Dead 2|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Left 4 Dead|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Left 4 Dead|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Old Metamod|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Old Metamod|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Orange Box Valve|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Orange Box Valve|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Orange Box|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release - Orange Box|Win32.Build.0 = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release|Win32.ActiveCfg = Release|Win32 - {C701A837-4258-45D1-93EF-85EDBA7D924A}.Release|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - CS GO|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - CSS|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - CSS|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Episode 1|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - EYE|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - EYE|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Old Metamod|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.CrazyDebug - Orange Box|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - CS GO|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - CS GO|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - CSS|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - CSS|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Episode 1|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - EYE|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - EYE|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Old Metamod|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug - Orange Box|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug|Win32.ActiveCfg = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Debug|Win32.Build.0 = Debug|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Alien Swarm|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Alien Swarm|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Bloody Good Time|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Bloody Good Time|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - CS GO|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - CS GO|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - CSS|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - CSS|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Dark Messiah|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Dark Messiah|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Episode 1|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Episode 1|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - EYE|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - EYE|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Left 4 Dead 2|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Left 4 Dead|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Left 4 Dead|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Old Metamod|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Old Metamod|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Orange Box Valve|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Orange Box Valve|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Orange Box|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release - Orange Box|Win32.Build.0 = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release|Win32.ActiveCfg = Release|Win32 - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE}.Release|Win32.Build.0 = Release|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug - Swarm|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Alien Swarm|Win32.Build.0 = Debug - Swarm|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug - Bloody Good Time|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Bloody Good Time|Win32.Build.0 = Debug - Bloody Good Time|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - CSS|Win32.ActiveCfg = Debug - CSS|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - CSS|Win32.Build.0 = Debug - CSS|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - EYE|Win32.ActiveCfg = Debug - EYE|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - EYE|Win32.Build.0 = Debug - EYE|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.CrazyDebug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Swarm|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Alien Swarm|Win32.Build.0 = Debug - Swarm|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug - Bloody Good Time|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Bloody Good Time|Win32.Build.0 = Debug - Bloody Good Time|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - CSS|Win32.ActiveCfg = Debug - CSS|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - CSS|Win32.Build.0 = Debug - CSS|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - EYE|Win32.ActiveCfg = Debug - EYE|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - EYE|Win32.Build.0 = Debug - EYE|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug|Win32.ActiveCfg = Debug - Bloody Good Time|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Debug|Win32.Build.0 = Debug - Bloody Good Time|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Alien Swarm|Win32.ActiveCfg = Release - Swarm|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Alien Swarm|Win32.Build.0 = Release - Swarm|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Bloody Good Time|Win32.ActiveCfg = Release - Bloody Good Time|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Bloody Good Time|Win32.Build.0 = Release - Bloody Good Time|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - CSS|Win32.ActiveCfg = Release - CSS|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - CSS|Win32.Build.0 = Release - CSS|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - EYE|Win32.ActiveCfg = Release - EYE|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - EYE|Win32.Build.0 = Release - EYE|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release|Win32.ActiveCfg = Release - Orange Box|Win32 - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432}.Release|Win32.Build.0 = Release - Orange Box|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Alien Swarm|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Bloody Good Time|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - CS GO|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - CS GO|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - CS GO|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - CSS|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - CSS|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - CSS|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Dark Messiah|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Episode 1|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Episode 1|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - EYE|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - EYE|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - EYE|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Left 4 Dead 2|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Left 4 Dead|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Old Metamod|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Old Metamod|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Orange Box Valve|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Orange Box|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.CrazyDebug - Orange Box|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Alien Swarm|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Alien Swarm|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Alien Swarm|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Bloody Good Time|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Bloody Good Time|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Bloody Good Time|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - CS GO|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - CS GO|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - CS GO|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - CSS|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - CSS|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - CSS|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Dark Messiah|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Dark Messiah|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Dark Messiah|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Episode 1|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Episode 1|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Episode 1|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - EYE|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - EYE|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - EYE|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Left 4 Dead 2|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Left 4 Dead|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Left 4 Dead|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Old Metamod|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Old Metamod|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Old Metamod|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Orange Box Valve|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Orange Box Valve|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Orange Box|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Orange Box|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug - Orange Box|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug|Win32.ActiveCfg = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug|Win32.Build.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Debug|Win32.Deploy.0 = Debug|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Alien Swarm|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Alien Swarm|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Alien Swarm|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Bloody Good Time|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Bloody Good Time|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Bloody Good Time|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - CS GO|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - CS GO|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - CS GO|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - CSS|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - CSS|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - CSS|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Dark Messiah|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Dark Messiah|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Dark Messiah|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Episode 1|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Episode 1|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Episode 1|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - EYE|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - EYE|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - EYE|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Left 4 Dead 2|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Left 4 Dead 2|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Left 4 Dead|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Left 4 Dead|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Left 4 Dead|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Old Metamod|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Old Metamod|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Old Metamod|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Orange Box Valve|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Orange Box Valve|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Orange Box Valve|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Orange Box|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Orange Box|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release - Orange Box|Win32.Deploy.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release|Win32.ActiveCfg = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release|Win32.Build.0 = Release|Win32 - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6}.Release|Win32.Deploy.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206} = {5F822FBB-6A18-4B35-8705-0D5CC734C08A} - {7A740927-C751-4312-BF9D-6367F8C508F8} = {5F822FBB-6A18-4B35-8705-0D5CC734C08A} - {E38F65D9-74B2-4373-B46A-DBB76F579F98} = {5F822FBB-6A18-4B35-8705-0D5CC734C08A} - {B3E8AF22-5436-49A4-9A3F-631519874372} = {5F822FBB-6A18-4B35-8705-0D5CC734C08A} - {18B5ED38-DBB7-47B2-8500-5648B8C1263B} = {5F822FBB-6A18-4B35-8705-0D5CC734C08A} - {C701A837-4258-45D1-93EF-85EDBA7D924A} = {5F822FBB-6A18-4B35-8705-0D5CC734C08A} - {B8EFDF82-546B-4E0F-85AA-D2E8CED542AE} = {5F822FBB-6A18-4B35-8705-0D5CC734C08A} - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432} = {5F822FBB-6A18-4B35-8705-0D5CC734C08A} - {3EF159C3-87E4-4BF9-98A3-9C36AA1036C6} = {5F822FBB-6A18-4B35-8705-0D5CC734C08A} - EndGlobalSection -EndGlobal diff --git a/plugins/admin-flatfile/admin-flatfile.sp b/plugins/admin-flatfile/admin-flatfile.sp index 12f06711..6e9bccd0 100644 --- a/plugins/admin-flatfile/admin-flatfile.sp +++ b/plugins/admin-flatfile/admin-flatfile.sp @@ -36,7 +36,7 @@ #include -public Plugin:myinfo = +public Plugin myinfo = { name = "Admin File Reader", author = "AlliedModders LLC", @@ -46,18 +46,18 @@ public Plugin:myinfo = }; /** Various parsing globals */ -new bool:g_LoggedFileName = false; /* Whether or not the file name has been logged */ -new g_ErrorCount = 0; /* Current error count */ -new g_IgnoreLevel = 0; /* Nested ignored section count, so users can screw up files safely */ -new g_CurrentLine = 0; /* Current line we're on */ -new String:g_Filename[PLATFORM_MAX_PATH]; /* Used for error messages */ +bool g_LoggedFileName = false; /* Whether or not the file name has been logged */ +int g_ErrorCount = 0; /* Current error count */ +int g_IgnoreLevel = 0; /* Nested ignored section count, so users can screw up files safely */ +int g_CurrentLine = 0; /* Current line we're on */ +char g_Filename[PLATFORM_MAX_PATH]; /* Used for error messages */ #include "admin-overrides.sp" #include "admin-groups.sp" #include "admin-users.sp" #include "admin-simple.sp" -public OnRebuildAdminCache(AdminCachePart:part) +public void OnRebuildAdminCache(AdminCachePart part) { if (part == AdminCache_Overrides) { @@ -70,9 +70,9 @@ public OnRebuildAdminCache(AdminCachePart:part) } } -ParseError(const String:format[], any:...) +void ParseError(const char[] format, any ...) { - decl String:buffer[512]; + char buffer[512]; if (!g_LoggedFileName) { @@ -87,7 +87,7 @@ ParseError(const String:format[], any:...) g_ErrorCount++; } -InitGlobalStates() +void InitGlobalStates() { g_ErrorCount = 0; g_IgnoreLevel = 0; diff --git a/plugins/admin-flatfile/admin-groups.sp b/plugins/admin-flatfile/admin-groups.sp index 95277578..986907e6 100644 --- a/plugins/admin-flatfile/admin-groups.sp +++ b/plugins/admin-flatfile/admin-groups.sp @@ -31,18 +31,26 @@ * Version: $Id$ */ -#define GROUP_STATE_NONE 0 -#define GROUP_STATE_GROUPS 1 -#define GROUP_STATE_INGROUP 2 -#define GROUP_STATE_OVERRIDES 3 -#define GROUP_PASS_FIRST 1 -#define GROUP_PASS_SECOND 2 +enum GroupState +{ + GroupState_None, + GroupState_Groups, + GroupState_InGroup, + GroupState_Overrides, +} + +enum GroupPass +{ + GroupPass_Invalid, + GroupPass_First, + GroupPass_Second, +} static SMCParser g_hGroupParser; -static GroupId:g_CurGrp = INVALID_GROUP_ID; -static g_GroupState = GROUP_STATE_NONE; -static g_GroupPass = 0; -static bool:g_NeedReparse = false; +static GroupId g_CurGrp = INVALID_GROUP_ID; +static GroupState g_GroupState = GroupState_None; +static GroupPass g_GroupPass = GroupPass_Invalid; +static bool g_NeedReparse = false; public SMCResult ReadGroups_NewSection(SMCParser smc, const char[] name, bool opt_quotes) { @@ -52,24 +60,24 @@ public SMCResult ReadGroups_NewSection(SMCParser smc, const char[] name, bool op return SMCParse_Continue; } - if (g_GroupState == GROUP_STATE_NONE) + if (g_GroupState == GroupState_None) { if (StrEqual(name, "Groups")) { - g_GroupState = GROUP_STATE_GROUPS; + g_GroupState = GroupState_Groups; } else { g_IgnoreLevel++; } - } else if (g_GroupState == GROUP_STATE_GROUPS) { + } else if (g_GroupState == GroupState_Groups) { if ((g_CurGrp = CreateAdmGroup(name)) == INVALID_GROUP_ID) { g_CurGrp = FindAdmGroup(name); } - g_GroupState = GROUP_STATE_INGROUP; - } else if (g_GroupState == GROUP_STATE_INGROUP) { + g_GroupState = GroupState_InGroup; + } else if (g_GroupState == GroupState_InGroup) { if (StrEqual(name, "Overrides")) { - g_GroupState = GROUP_STATE_OVERRIDES; + g_GroupState = GroupState_Overrides; } else { g_IgnoreLevel++; } @@ -91,28 +99,28 @@ public SMCResult ReadGroups_KeyValue(SMCParser smc, return SMCParse_Continue; } - new AdminFlag:flag; + AdminFlag flag; - if (g_GroupPass == GROUP_PASS_FIRST) + if (g_GroupPass == GroupPass_First) { - if (g_GroupState == GROUP_STATE_INGROUP) + if (g_GroupState == GroupState_InGroup) { if (StrEqual(key, "flags")) { - new len = strlen(value); - for (new i=0; i 0) { - SetAdminImmunityLevel(admin, level); + admin.ImmunityLevel = level; if (flags[flag_idx] == ':') { flag_idx++; @@ -166,41 +166,41 @@ ReadAdminLine(const String:line[]) if (flags[flag_idx] == '@') { - new GroupId:gid = FindAdmGroup(flags[flag_idx + 1]); + GroupId gid = FindAdmGroup(flags[flag_idx + 1]); if (gid == INVALID_GROUP_ID) { ParseError("Invalid group detected: %s", flags[flag_idx + 1]); return; } - AdminInheritGroup(admin, gid); + admin.InheritGroup(gid); } else { - new len = strlen(flags[flag_idx]); - new bool:is_default = false; - for (new i=0; i -public Plugin:myinfo = +public Plugin myinfo = { name = "SQL Admins (Prefetch)", author = "AlliedModders LLC", @@ -45,7 +45,7 @@ public Plugin:myinfo = url = "http://www.sourcemod.net/" }; -public OnRebuildAdminCache(AdminCachePart:part) +public void OnRebuildAdminCache(AdminCachePart part) { /* First try to get a database connection */ char error[255]; @@ -97,7 +97,7 @@ void FetchUsers(Database db) char name[80]; int immunity; AdminId adm; - GroupId gid; + GroupId grp; int id; /* Keep track of a mapping from admin DB IDs to internal AdminIds to @@ -120,7 +120,7 @@ void FetchUsers(Database db) if ((adm = FindAdminByIdentity(authtype, identity)) == INVALID_ADMIN_ID) { adm = CreateAdmin(name); - if (!BindAdminIdentity(adm, authtype, identity)) + if (!adm.BindIdentity(authtype, identity)) { LogError("Could not bind prefetched SQL admin (authtype \"%s\") (identity \"%s\")", authtype, identity); continue; @@ -136,22 +136,22 @@ void FetchUsers(Database db) /* See if this admin wants a password */ if (password[0] != '\0') { - SetAdminPassword(adm, password); + adm.SetPassword(password); } /* Apply each flag */ int len = strlen(flags); AdminFlag flag; - for (new i=0; i -public Plugin:myinfo = +public Plugin myinfo = { name = "SQL Admins (Threaded)", author = "AlliedModders LLC", @@ -68,15 +68,15 @@ public Plugin:myinfo = */ Database hDatabase = null; /** Database connection */ -new g_sequence = 0; /** Global unique sequence number */ -new ConnectLock = 0; /** Connect sequence number */ -new RebuildCachePart[3] = {0}; /** Cache part sequence numbers */ -new PlayerSeq[MAXPLAYERS+1]; /** Player-specific sequence numbers */ -new bool:PlayerAuth[MAXPLAYERS+1]; /** Whether a player has been "pre-authed" */ +int g_sequence = 0; /** Global unique sequence number */ +int ConnectLock = 0; /** Connect sequence number */ +int RebuildCachePart[3] = {0}; /** Cache part sequence numbers */ +int PlayerSeq[MAXPLAYERS+1]; /** Player-specific sequence numbers */ +bool PlayerAuth[MAXPLAYERS+1]; /** Whether a player has been "pre-authed" */ //#define _DEBUG -public OnMapEnd() +public void OnMapEnd() { /** * Clean up on map end just so we can start a fresh connection when we need it later. @@ -84,14 +84,14 @@ public OnMapEnd() delete hDatabase; } -public bool:OnClientConnect(client, String:rejectmsg[], maxlen) +public bool OnClientConnect(int client, char[] rejectmsg, int maxlen) { PlayerSeq[client] = 0; PlayerAuth[client] = false; return true; } -public OnClientDisconnect(client) +public void OnClientDisconnect(int client) { PlayerSeq[client] = 0; PlayerAuth[client] = false; @@ -128,22 +128,22 @@ public void OnDatabaseConnect(Database db, const char[] error, any data) /** * See if we need to get any of the cache stuff now. */ - new sequence; - if ((sequence = RebuildCachePart[_:AdminCache_Overrides]) != 0) + int sequence; + if ((sequence = RebuildCachePart[AdminCache_Overrides]) != 0) { FetchOverrides(hDatabase, sequence); } - if ((sequence = RebuildCachePart[_:AdminCache_Groups]) != 0) + if ((sequence = RebuildCachePart[AdminCache_Groups]) != 0) { FetchGroups(hDatabase, sequence); } - if ((sequence = RebuildCachePart[_:AdminCache_Admins]) != 0) + if ((sequence = RebuildCachePart[AdminCache_Admins]) != 0) { FetchUsersWeCan(hDatabase); } } -RequestDatabaseConnection() +void RequestDatabaseConnection() { ConnectLock = ++g_sequence; if (SQL_CheckConfig("admins")) @@ -154,7 +154,7 @@ RequestDatabaseConnection() } } -public OnRebuildAdminCache(AdminCachePart part) +public void OnRebuildAdminCache(AdminCachePart part) { /** * Mark this part of the cache as being rebuilt. This is used by the @@ -162,7 +162,7 @@ public OnRebuildAdminCache(AdminCachePart part) * used. */ int sequence = ++g_sequence; - RebuildCachePart[_:part] = sequence; + RebuildCachePart[part] = sequence; /** * If we don't have a database connection, we can't do any lookups just yet. @@ -189,7 +189,7 @@ public OnRebuildAdminCache(AdminCachePart part) } } -public Action OnClientPreAdminCheck(client) +public Action OnClientPreAdminCheck(int client) { PlayerAuth[client] = true; @@ -209,7 +209,7 @@ public Action OnClientPreAdminCheck(client) * the user's normal connection flow. The database will soon auth the user * normally. */ - if (RebuildCachePart[_:AdminCache_Admins] != 0) + if (RebuildCachePart[AdminCache_Admins] != 0) { return Plugin_Continue; } @@ -272,22 +272,22 @@ public void OnReceiveUserGroups(Database db, DBResultSet rs, const char[] error, } char name[80]; - GroupId gid; + GroupId grp; while (rs.FetchRow()) { rs.FetchString(0, name, sizeof(name)); - if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID) + if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID) { continue; } #if defined _DEBUG - PrintToServer("Binding user group (%d, %d, %d, %s, %d)", client, sequence, adm, name, gid); + PrintToServer("Binding user group (%d, %d, %d, %s, %d)", client, sequence, adm, name, grp); #endif - AdminInheritGroup(adm, gid); + adm.InheritGroup(grp); } /** @@ -350,7 +350,7 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d /** * Cache user info -- [0] = db id, [1] = cache id, [2] = groups */ - char[][] user_lookup = new char[num_accounts][3]; + int[][] user_lookup = new int[num_accounts][3]; int total_users = 0; while (rs.FetchRow()) @@ -370,14 +370,14 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d } adm = CreateAdmin(name); - if (!BindAdminIdentity(adm, authtype, identity)) + if (!adm.BindIdentity(authtype, identity)) { LogError("Could not bind prefetched SQL admin (authtype \"%s\") (identity \"%s\")", authtype, identity); continue; } user_lookup[total_users][0] = id; - user_lookup[total_users][1] = _:adm; + user_lookup[total_users][1] = view_as(adm); user_lookup[total_users][2] = rs.FetchInt(6); total_users++; @@ -388,21 +388,21 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d /* See if this admin wants a password */ if (password[0] != '\0') { - SetAdminPassword(adm, password); + adm.SetPassword(password); } - SetAdminImmunityLevel(adm, immunity); + adm.ImmunityLevel = immunity; /* Apply each flag */ int len = strlen(flags); AdminFlag flag; - for (new i=0; i(adm)) { id = user_lookup[i][0]; group_count = user_lookup[i][2]; @@ -449,16 +449,16 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d pk.Reset(); pk.WriteCell(client); pk.WriteCell(sequence); - pk.WriteCell(_:adm); + pk.WriteCell(adm); pk.WriteString(query); db.Query(OnReceiveUserGroups, query, pk, DBPrio_High); } -FetchUser(Database db, client) +void FetchUser(Database db, int client) { - char name[65]; - char safe_name[140]; + char name[MAX_NAME_LENGTH]; + char safe_name[(MAX_NAME_LENGTH * 2) - 1]; char steamid[32]; char steamidalt[32]; char ipaddr[24]; @@ -484,7 +484,7 @@ FetchUser(Database db, client) * Construct the query using the information the user gave us. */ char query[512]; - new len = 0; + int len = 0; len += Format(query[len], sizeof(query)-len, "SELECT a.id, a.authtype, a.identity, a.password, a.flags, a.name, COUNT(ag.group_id), immunity"); len += Format(query[len], sizeof(query)-len, " FROM sm_admins a LEFT JOIN sm_admins_groups ag ON a.id = ag.admin_id WHERE "); @@ -516,7 +516,7 @@ FetchUser(Database db, client) db.Query(OnReceiveUser, query, pk, DBPrio_High); } -FetchUsersWeCan(Database db) +void FetchUsersWeCan(Database db) { for (int i=1; i<=MaxClients; i++) { @@ -529,7 +529,7 @@ FetchUsersWeCan(Database db) /** * This round of updates is done. Go in peace. */ - RebuildCachePart[_:AdminCache_Admins] = 0; + RebuildCachePart[AdminCache_Admins] = 0; } @@ -542,7 +542,7 @@ public void OnReceiveGroupImmunity(Database db, DBResultSet rs, const char[] err * Check if this is the latest result request. */ int sequence = pk.ReadCell(); - if (RebuildCachePart[_:AdminCache_Groups] != sequence) + if (RebuildCachePart[AdminCache_Groups] != sequence) { /* Discard everything, since we're out of sequence. */ delete pk; @@ -569,28 +569,28 @@ public void OnReceiveGroupImmunity(Database db, DBResultSet rs, const char[] err { char group1[80]; char group2[80]; - GroupId gid1, gid2; + GroupId grp, other; rs.FetchString(0, group1, sizeof(group1)); rs.FetchString(1, group2, sizeof(group2)); - if (((gid1 = FindAdmGroup(group1)) == INVALID_GROUP_ID) - || (gid2 = FindAdmGroup(group2)) == INVALID_GROUP_ID) + if (((grp = FindAdmGroup(group1)) == INVALID_GROUP_ID) + || (other = FindAdmGroup(group2)) == INVALID_GROUP_ID) { continue; } - SetAdmGroupImmuneFrom(gid1, gid2); + grp.AddGroupImmunity(other); #if defined _DEBUG - PrintToServer("SetAdmGroupImmuneFrom(%d, %d)", gid1, gid2); + PrintToServer("SetAdmGroupImmuneFrom(%d, %d)", grp, other); #endif } /* Clear the sequence so another connect doesn't refetch */ - RebuildCachePart[_:AdminCache_Groups] = 0; + RebuildCachePart[AdminCache_Groups] = 0; } -public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, any data) +public void OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, any data) { DataPack pk = view_as(data); pk.Reset(); @@ -599,7 +599,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, * Check if this is the latest result request. */ int sequence = pk.ReadCell(); - if (RebuildCachePart[_:AdminCache_Groups] != sequence) + if (RebuildCachePart[AdminCache_Groups] != sequence) { /* Discard everything, since we're out of sequence. */ delete pk; @@ -626,7 +626,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, char type[16]; char command[64]; char access[16]; - GroupId gid; + GroupId grp; while (rs.FetchRow()) { rs.FetchString(0, name, sizeof(name)); @@ -635,7 +635,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, rs.FetchString(3, access, sizeof(access)); /* Find the group. This is actually faster than doing the ID lookup. */ - if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID) + if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID) { /* Oh well, just ignore it. */ continue; @@ -654,10 +654,10 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, } #if defined _DEBUG - PrintToServer("AddAdmGroupCmdOverride(%d, %s, %d, %d)", gid, command, o_type, o_rule); + PrintToServer("AddAdmGroupCmdOverride(%d, %s, %d, %d)", grp, command, o_type, o_rule); #endif - AddAdmGroupCmdOverride(gid, command, o_type, o_rule); + grp.AddCommandOverride(command, o_type, o_rule); } /** @@ -676,7 +676,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, db.Query(OnReceiveGroupImmunity, query, pk, DBPrio_High); } -public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data) +public void OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data) { DataPack pk = view_as(data); pk.Reset(); @@ -685,7 +685,7 @@ public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data * Check if this is the latest result request. */ int sequence = pk.ReadCell(); - if (RebuildCachePart[_:AdminCache_Groups] != sequence) + if (RebuildCachePart[AdminCache_Groups] != sequence) { /* Discard everything, since we're out of sequence. */ delete pk; @@ -722,25 +722,25 @@ public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data #endif /* Find or create the group */ - GroupId gid; - if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID) + GroupId grp; + if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID) { - gid = CreateAdmGroup(name); + grp = CreateAdmGroup(name); } /* Add flags from the database to the group */ int num_flag_chars = strlen(flags); for (int i=0; i 1) { - new i; - new EndCmd = (PageNum-1) * COMMANDS_PER_PAGE - 1; + int i; + int EndCmd = (PageNum-1) * COMMANDS_PER_PAGE - 1; for (i=0; ReadCommandIterator(CmdIter, Name, sizeof(Name), Flags, Desc, sizeof(Desc)) && i #include -public Plugin:myinfo = +public Plugin myinfo = { name = "Admin Menu", author = "AlliedModders LLC", @@ -46,8 +46,8 @@ public Plugin:myinfo = }; /* Forwards */ -new Handle:hOnAdminMenuReady = null; -new Handle:hOnAdminMenuCreated = null; +Handle hOnAdminMenuReady = null; +Handle hOnAdminMenuCreated = null; /* Menus */ TopMenu hAdminMenu; @@ -59,7 +59,7 @@ TopMenuObject obj_votingcmds = INVALID_TOPMENUOBJECT; #include "adminmenu/dynamicmenu.sp" -public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) +public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) { CreateNative("GetAdminTopMenu", __GetAdminTopMenu); CreateNative("AddTargetsToMenu", __AddTargetsToMenu); @@ -68,7 +68,7 @@ public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) return APLRes_Success; } -public OnPluginStart() +public void OnPluginStart() { LoadTranslations("common.phrases"); LoadTranslations("adminmenu.phrases"); @@ -79,10 +79,10 @@ public OnPluginStart() RegAdminCmd("sm_admin", Command_DisplayMenu, ADMFLAG_GENERIC, "Displays the admin menu"); } -public OnConfigsExecuted() +public void OnConfigsExecuted() { - decl String:path[PLATFORM_MAX_PATH]; - decl String:error[256]; + char path[PLATFORM_MAX_PATH]; + char error[256]; BuildPath(Path_SM, path, sizeof(path), "configs/adminmenu_sorting.txt"); @@ -93,12 +93,12 @@ public OnConfigsExecuted() } } -public OnMapStart() +public void OnMapStart() { ParseConfigs(); } -public OnAllPluginsLoaded() +public void OnAllPluginsLoaded() { hAdminMenu = new TopMenu(DefaultCategoryHandler); @@ -117,12 +117,12 @@ public OnAllPluginsLoaded() Call_Finish(); } -public DefaultCategoryHandler(Handle:topmenu, - TopMenuAction:action, - TopMenuObject:object_id, - param, - String:buffer[], - maxlength) +public void DefaultCategoryHandler(Handle topmenu, + TopMenuAction action, + TopMenuObject object_id, + int param, + char[] buffer, + int maxlength) { if (action == TopMenuAction_DisplayTitle) { @@ -160,14 +160,14 @@ public DefaultCategoryHandler(Handle:topmenu, } } -public __GetAdminTopMenu(Handle:plugin, numParams) +public int __GetAdminTopMenu(Handle plugin, int numParams) { - return _:hAdminMenu; + return view_as(hAdminMenu); } -public __AddTargetsToMenu(Handle:plugin, numParams) +public int __AddTargetsToMenu(Handle plugin, int numParams) { - new bool:alive_only = false; + bool alive_only = false; if (numParams >= 4) { @@ -177,12 +177,12 @@ public __AddTargetsToMenu(Handle:plugin, numParams) return UTIL_AddTargetsToMenu(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3), alive_only); } -public __AddTargetsToMenu2(Handle:plugin, numParams) +public int __AddTargetsToMenu2(Handle plugin, int numParams) { return UTIL_AddTargetsToMenu2(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3)); } -public Action:Command_DisplayMenu(int client, int args) +public Action Command_DisplayMenu(int client, int args) { if (client == 0) { @@ -194,15 +194,15 @@ public Action:Command_DisplayMenu(int client, int args) return Plugin_Handled; } -stock int UTIL_AddTargetsToMenu2(Menu menu, source_client, flags) +stock int UTIL_AddTargetsToMenu2(Menu menu, int source_client, int flags) { char user_id[12]; char name[MAX_NAME_LENGTH]; char display[MAX_NAME_LENGTH+12]; - new num_clients; + int num_clients; - for (new i = 1; i <= MaxClients; i++) + for (int i = 1; i <= MaxClients; i++) { if (!IsClientConnected(i) || IsClientInKickQueue(i)) { @@ -249,9 +249,9 @@ stock int UTIL_AddTargetsToMenu2(Menu menu, source_client, flags) return num_clients; } -stock UTIL_AddTargetsToMenu(Menu menu, source_client, bool:in_game_only, bool:alive_only) +stock int UTIL_AddTargetsToMenu(Menu menu, int source_client, bool in_game_only, bool alive_only) { - new flags = 0; + int flags = 0; if (!in_game_only) { diff --git a/plugins/adminmenu/dynamicmenu.sp b/plugins/adminmenu/dynamicmenu.sp index 0bc11d44..bb8e4723 100644 --- a/plugins/adminmenu/dynamicmenu.sp +++ b/plugins/adminmenu/dynamicmenu.sp @@ -6,12 +6,12 @@ enum GroupCommands { - Handle:groupListName, - Handle:groupListCommand + ArrayList:groupListName, + ArrayList:groupListCommand }; -new g_groupList[GroupCommands]; -new g_groupCount; +int g_groupList[GroupCommands]; +int g_groupCount; SMCParser g_configParser; @@ -19,11 +19,11 @@ enum Places { Place_Category, Place_Item, - Place_ReplaceNum + Place_ReplaceNum }; -new String:g_command[MAXPLAYERS+1][CMD_LENGTH]; -new g_currentPlace[MAXPLAYERS+1][Places]; +char g_command[MAXPLAYERS+1][CMD_LENGTH]; +int g_currentPlace[MAXPLAYERS+1][Places]; /** * What to put in the 'info' menu field (for PlayerList and Player_Team menus only) @@ -58,7 +58,7 @@ enum Item { String:Item_cmd[256], ExecuteType:Item_execute, - Handle:Item_submenus + ArrayList:Item_submenus } enum Submenu @@ -67,12 +67,12 @@ enum Submenu String:Submenu_title[32], PlayerMethod:Submenu_method, Submenu_listcount, - Handle:Submenu_listdata + DataPack:Submenu_listdata } -new Handle:g_DataArray; +ArrayList g_DataArray; -BuildDynamicMenu() +void BuildDynamicMenu() { int itemInput[Item]; g_DataArray = CreateArray(sizeof(itemInput)); @@ -98,15 +98,15 @@ BuildDynamicMenu() FileToKeyValues(kvMenu, file); - new String:name[NAME_LENGTH]; - new String:buffer[NAME_LENGTH]; + char name[NAME_LENGTH]; + char buffer[NAME_LENGTH]; if (!kvMenu.GotoFirstSubKey()) return; - decl String:admin[30]; + char admin[30]; - new TopMenuObject:categoryId; + TopMenuObject categoryId; do { @@ -124,7 +124,7 @@ BuildDynamicMenu() } - decl String:category_name[NAME_LENGTH]; + char category_name[NAME_LENGTH]; strcopy(category_name, sizeof(category_name), buffer); if (!kvMenu.GotoFirstSubKey()) @@ -143,7 +143,7 @@ BuildDynamicMenu() //No 'admin' keyvalue was found //Use the first argument of the 'cmd' string instead - decl String:temp[64]; + char temp[64]; kvMenu.GetString("cmd", temp, sizeof(temp),""); BreakString(temp, admin, sizeof(admin)); @@ -162,16 +162,16 @@ BuildDynamicMenu() itemInput[Item_execute] = Execute_Player; } - /* iterate all submenus and load data into itemInput[Item_submenus] (adt array handle) */ + /* iterate all submenus and load data into itemInput[Item_submenus] (ArrayList) */ - new count = 1; - decl String:countBuffer[10] = "1"; + int count = 1; + char countBuffer[10] = "1"; - decl String:inputBuffer[48]; + char inputBuffer[48]; while (kvMenu.JumpToKey(countBuffer)) { - new submenuInput[Submenu]; + int submenuInput[Submenu]; if (count == 1) { @@ -198,8 +198,8 @@ BuildDynamicMenu() kvMenu.GetString("path", inputBuffer, sizeof(inputBuffer),"mapcycle.txt"); submenuInput[Submenu_listdata] = CreateDataPack(); - WritePackString(submenuInput[Submenu_listdata], inputBuffer); - ResetPack(submenuInput[Submenu_listdata]); + submenuInput[Submenu_listdata].WriteString(inputBuffer); + submenuInput[Submenu_listdata].Reset(); } else if (StrContains(inputBuffer, "player") != -1) { @@ -215,14 +215,14 @@ BuildDynamicMenu() submenuInput[Submenu_listdata] = CreateDataPack(); - new String:temp[6]; - new String:value[64]; - new String:text[64]; - new String:subadm[30]; // same as "admin", cf. line 110 - new i=1; - new bool:more = true; + char temp[6]; + char value[64]; + char text[64]; + char subadm[30]; // same as "admin", cf. line 110 + int i=1; + bool more = true; - new listcount = 0; + int listcount = 0; do { @@ -242,16 +242,16 @@ BuildDynamicMenu() else { listcount++; - WritePackString(submenuInput[Submenu_listdata], value); - WritePackString(submenuInput[Submenu_listdata], text); - WritePackString(submenuInput[Submenu_listdata], subadm); + submenuInput[Submenu_listdata].WriteString(value); + submenuInput[Submenu_listdata].WriteString(text); + submenuInput[Submenu_listdata].WriteString(subadm); } i++; } while (more); - ResetPack(submenuInput[Submenu_listdata]); + submenuInput[Submenu_listdata].Reset(); submenuInput[Submenu_listcount] = listcount; } @@ -291,16 +291,16 @@ BuildDynamicMenu() count++; Format(countBuffer, sizeof(countBuffer), "%i", count); - PushArrayArray(itemInput[Item_submenus], submenuInput[0]); + itemInput[Item_submenus].PushArray(submenuInput[0]); kvMenu.GoBack(); } /* Save this entire item into the global items array and add it to the menu */ - new location = PushArrayArray(g_DataArray, itemInput[0]); + int location = g_DataArray.PushArray(itemInput[0]); - decl String:locString[10]; + char locString[10]; IntToString(location, locString, sizeof(locString)); if (hAdminMenu.AddItem(buffer, @@ -322,7 +322,7 @@ BuildDynamicMenu() delete kvMenu; } -ParseConfigs() +void ParseConfigs() { if (!g_configParser) g_configParser = new SMCParser(); @@ -331,20 +331,13 @@ ParseConfigs() g_configParser.OnKeyValue = KeyValue; g_configParser.OnLeaveSection = EndSection; - if (g_groupList[groupListName] != INVALID_HANDLE) - { - CloseHandle(g_groupList[groupListName]); - } - - if (g_groupList[groupListCommand] != null) - { - CloseHandle(g_groupList[groupListCommand]); - } + delete g_groupList[groupListName]; + delete g_groupList[groupListCommand]; g_groupList[groupListName] = CreateArray(ARRAY_STRING_LENGTH); g_groupList[groupListCommand] = CreateArray(ARRAY_STRING_LENGTH); - decl String:configPath[256]; + char configPath[256]; BuildPath(Path_SM, configPath, sizeof(configPath), "configs/dynamicmenu/adminmenu_grouping.txt"); if (FileExists(configPath)) { @@ -367,7 +360,7 @@ ParseConfigs() SMCError err = g_configParser.ParseFile(configPath, line); if (err != SMCError_Okay) { - decl String:error[256]; + char error[256]; SMC_GetErrorString(err, error, sizeof(error)); LogError("Could not parse file (line %d, file \"%s\"):", line, configPath); LogError("Parser encountered error: %s", error); @@ -383,48 +376,48 @@ public SMCResult NewSection(SMCParser smc, const char[] name, bool opt_quotes) public SMCResult KeyValue(SMCParser smc, const char[] key, const char[] value, bool key_quotes, bool value_quotes) { - PushArrayString(g_groupList[groupListName], key); - PushArrayString(g_groupList[groupListCommand], value); + g_groupList[groupListName].PushString(key); + g_groupList[groupListCommand].PushString(value); } public SMCResult EndSection(SMCParser smc) { - g_groupCount = GetArraySize(g_groupList[groupListName]); + g_groupCount = g_groupList[groupListName].Length; } -public DynamicMenuCategoryHandler(Handle:topmenu, - TopMenuAction:action, - TopMenuObject:object_id, - param, - String:buffer[], - maxlength) +public void DynamicMenuCategoryHandler(TopMenu topmenu, + TopMenuAction action, + TopMenuObject object_id, + int param, + char[] buffer, + int maxlength) { if ((action == TopMenuAction_DisplayTitle) || (action == TopMenuAction_DisplayOption)) { - GetTopMenuObjName(topmenu, object_id, buffer, maxlength); + topmenu.GetObjName(object_id, buffer, maxlength); } } -public DynamicMenuItemHandler(Handle:topmenu, - TopMenuAction:action, - TopMenuObject:object_id, - param, - String:buffer[], - maxlength) +public void DynamicMenuItemHandler(TopMenu topmenu, + TopMenuAction action, + TopMenuObject object_id, + int param, + char[] buffer, + int maxlength) { if (action == TopMenuAction_DisplayOption) { - GetTopMenuObjName(topmenu, object_id, buffer, maxlength); + topmenu.GetObjName(object_id, buffer, maxlength); } else if (action == TopMenuAction_SelectOption) { - new String:locString[10]; - GetTopMenuInfoString(topmenu, object_id, locString, sizeof(locString)); + char locString[10]; + topmenu.GetInfoString(object_id, locString, sizeof(locString)); - new location = StringToInt(locString); + int location = StringToInt(locString); - new output[Item]; - GetArrayArray(g_DataArray, location, output[0]); + int output[Item]; + g_DataArray.GetArray(location, output[0]); strcopy(g_command[param], sizeof(g_command[]), output[Item_cmd]); @@ -435,15 +428,15 @@ public DynamicMenuItemHandler(Handle:topmenu, } } -public ParamCheck(client) +public void ParamCheck(int client) { - new String:buffer[6]; - new String:buffer2[6]; + char buffer[6]; + char buffer2[6]; - new outputItem[Item]; - new outputSubmenu[Submenu]; + int outputItem[Item]; + int outputSubmenu[Submenu]; - GetArrayArray(g_DataArray, g_currentPlace[client][Place_Item], outputItem[0]); + g_DataArray.GetArray(g_currentPlace[client][Place_Item], outputItem[0]); if (g_currentPlace[client][Place_ReplaceNum] < 1) { @@ -455,29 +448,29 @@ public ParamCheck(client) if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1) { - GetArrayArray(outputItem[Item_submenus], g_currentPlace[client][Place_ReplaceNum] - 1, outputSubmenu[0]); + outputItem[Item_submenus].GetArray(g_currentPlace[client][Place_ReplaceNum] - 1, outputSubmenu[0]); Menu itemMenu = CreateMenu(Menu_Selection); itemMenu.ExitBackButton = true; if ((outputSubmenu[Submenu_type] == SubMenu_Group) || (outputSubmenu[Submenu_type] == SubMenu_GroupPlayer)) { - decl String:nameBuffer[ARRAY_STRING_LENGTH]; - decl String:commandBuffer[ARRAY_STRING_LENGTH]; + char nameBuffer[ARRAY_STRING_LENGTH]; + char commandBuffer[ARRAY_STRING_LENGTH]; - for (new i = 0; i(flag)); } /** @@ -616,9 +761,9 @@ stock FlagToBit(AdminFlag:flag) * @param flag Stores the converted flag by reference. * @return True on success, false otherwise. */ -stock bool:BitToFlag(bit, &AdminFlag:flag) +stock bool BitToFlag(int bit, AdminFlag &flag) { - new AdminFlag:array[1]; + AdminFlag array[1]; if (FlagBitsToArray(bit, array, 1)) { diff --git a/plugins/include/adminmenu.inc b/plugins/include/adminmenu.inc index b3662c04..f80586e2 100644 --- a/plugins/include/adminmenu.inc +++ b/plugins/include/adminmenu.inc @@ -63,17 +63,15 @@ * the Handle or add categories. * * @param topmenu Handle to the admin menu's TopMenu. - * @noreturn */ -forward OnAdminMenuCreated(Handle topmenu); +forward void OnAdminMenuCreated(Handle topmenu); /** * Called when the admin menu is ready to have items added. * * @param topmenu Handle to the admin menu's TopMenu. - * @noreturn */ -forward OnAdminMenuReady(Handle topmenu); +forward void OnAdminMenuReady(Handle topmenu); /** * Retrieves the Handle to the admin top menu. diff --git a/plugins/include/adt_array.inc b/plugins/include/adt_array.inc index 3bd3378d..204fc8f5 100644 --- a/plugins/include/adt_array.inc +++ b/plugins/include/adt_array.inc @@ -9,7 +9,7 @@ * 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 @@ -29,14 +29,14 @@ * * Version: $Id$ */ - + #if defined _adt_array_included #endinput #endif #define _adt_array_included /** - * Given a maximum string size (including the null terminator), + * Given a maximum string size (including the null terminator), * returns the number of cells required to fit that string. * * @param size Number of bytes. @@ -52,16 +52,16 @@ stock ByteCountToCells(size) methodmap ArrayList < Handle { // Creates a dynamic global cell array. While slower than a normal array, // it can be used globally AND dynamically, which is otherwise impossible. - // - // The contents of the array are uniform; i.e. storing a string at index X + // + // The contents of the array are uniform; i.e. storing a string at index X // and then retrieving it as an integer is NOT the same as StringToInt()! // The "blocksize" determines how many cells each array slot has; it cannot // be changed after creation. // - // @param blocksize The number of cells each member of the array can + // @param blocksize The number of cells each member of the array can // hold. For example, 32 cells is equivalent to: // new Array[X][32] - // @param startsize Initial size of the array. Note that data will + // @param startsize Initial size of the array. Note that data will // NOT be auto-intialized. // @return New Handle to the array object. public native ArrayList(int blocksize=1, int startsize=0); @@ -106,7 +106,7 @@ methodmap ArrayList < Handle { // // @param values Block of values to copy. // @param size If not set, the number of elements copied from the array - // will be equal to the blocksize. If set higher than the + // will be equal to the blocksize. If set higher than the // blocksize, the operation will be truncated. // @return Index of the new entry. public native int PushArray(const any[] values, int size=-1); @@ -168,15 +168,15 @@ methodmap ArrayList < Handle { // @error Invalid index. public native void SetArray(int index, const any[] values, int size=-1); - // Shifts an array up. All array contents after and including the given - // index are shifted up by one, and the given index is then "free." + // Shifts an array up. All array contents after and including the given + // index are shifted up by one, and the given index is then "free." // After shifting, the contents of the given index is undefined. // // @param index Index in the array to shift up from. // @error Invalid index. public native void ShiftUp(int index); - // Removes an array index, shifting the entire array down from that position + // Removes an array index, shifting the entire array down from that position // on. For example, if item 8 of 10 is removed, the last 3 items will then be // (6,7,8) instead of (7,8,9), and all indexes before 8 will remain unchanged. // @@ -197,13 +197,15 @@ methodmap ArrayList < Handle { // @param item String to search for // @return Array index, or -1 on failure public native int FindString(const char[] item); - + // Returns the index for the first occurance of the provided value. If the // value cannot be located, -1 will be returned. // // @param item Value to search for + // @param block Optionally which block to search in // @return Array index, or -1 on failure - public native int FindValue(any item); + // @error Invalid block index + public native int FindValue(any item, int block=0); // Retrieve the size of the array. property int Length { @@ -214,16 +216,16 @@ methodmap ArrayList < Handle { /** * Creates a dynamic global cell array. While slower than a normal array, * it can be used globally AND dynamically, which is otherwise impossible. - * - * The contents of the array are uniform; i.e. storing a string at index X + * + * The contents of the array are uniform; i.e. storing a string at index X * and then retrieving it as an integer is NOT the same as StringToInt()! * The "blocksize" determines how many cells each array slot has; it cannot * be changed after creation. * - * @param blocksize The number of cells each member of the array can + * @param blocksize The number of cells each member of the array can * hold. For example, 32 cells is equivalent to: * new Array[X][32] - * @param startsize Initial size of the array. Note that data will + * @param startsize Initial size of the array. Note that data will * NOT be auto-intialized. * @return New Handle to the array object. */ @@ -300,7 +302,7 @@ native int PushArrayString(Handle array, const char[] value); * @param array Array Handle. * @param values Block of values to copy. * @param size If not set, the number of elements copied from the array - * will be equal to the blocksize. If set higher than the + * will be equal to the blocksize. If set higher than the * blocksize, the operation will be truncated. * @return Index of the new entry. * @error Invalid Handle or out of memory. @@ -383,8 +385,8 @@ native int SetArrayString(Handle array, int index, const char[] value); native int SetArrayArray(Handle array, int index, const any[] values, int size=-1); /** - * Shifts an array up. All array contents after and including the given - * index are shifted up by one, and the given index is then "free." + * Shifts an array up. All array contents after and including the given + * index are shifted up by one, and the given index is then "free." * After shifting, the contents of the given index is undefined. * * @param array Array Handle. @@ -394,7 +396,7 @@ native int SetArrayArray(Handle array, int index, const any[] values, int size=- native void ShiftArrayUp(Handle array, int index); /** - * Removes an array index, shifting the entire array down from that position + * Removes an array index, shifting the entire array down from that position * on. For example, if item 8 of 10 is removed, the last 3 items will then be * (6,7,8) instead of (7,8,9), and all indexes before 8 will remain unchanged. * @@ -424,14 +426,15 @@ native void SwapArrayItems(Handle array, int index1, int index2); * @error Invalid Handle */ native int FindStringInArray(Handle array, const char[] item); - + /** * Returns the index for the first occurance of the provided value. If the value * cannot be located, -1 will be returned. * * @param array Array Handle. * @param item Value to search for + * @param block Optionally which block to search in * @return Array index, or -1 on failure - * @error Invalid Handle + * @error Invalid Handle or invalid block */ -native int FindValueInArray(Handle array, any item); +native int FindValueInArray(Handle array, any item, int block=0); diff --git a/plugins/include/basecomm.inc b/plugins/include/basecomm.inc index 4f9c6bb1..139b8241 100644 --- a/plugins/include/basecomm.inc +++ b/plugins/include/basecomm.inc @@ -41,7 +41,7 @@ * @param client Client index * @param muteState True if client was muted, false otherwise */ - forward BaseComm_OnClientMute(client, bool:muteState); + forward void BaseComm_OnClientMute(client, bool:muteState); /** * Called when a client is gagged or ungagged @@ -49,7 +49,7 @@ * @param client Client index * @param gagState True if client was gaged, false otherwise */ - forward BaseComm_OnClientGag(client, bool:gagState); + forward void BaseComm_OnClientGag(client, bool:gagState); /** * Returns whether or not a client is gagged diff --git a/plugins/include/clientprefs.inc b/plugins/include/clientprefs.inc index ce4a66ca..62b20ff8 100644 --- a/plugins/include/clientprefs.inc +++ b/plugins/include/clientprefs.inc @@ -156,7 +156,7 @@ native bool:AreClientCookiesCached(client); * * @param client Client index. */ -forward OnClientCookiesCached(client); +forward void OnClientCookiesCached(client); /** * Cookie Menu Callback prototype diff --git a/plugins/include/clients.inc b/plugins/include/clients.inc index d914e823..226ce3a9 100644 --- a/plugins/include/clients.inc +++ b/plugins/include/clients.inc @@ -67,9 +67,6 @@ enum AuthIdType /** * MAXPLAYERS is not the same as MaxClients. * MAXPLAYERS is a hardcoded value as an upper limit. MaxClients changes based on the server. - * - * Both GetMaxClients() and MaxClients are only available once the map is loaded, and should - * not be used in OnPluginStart(). */ #define MAXPLAYERS 65 /**< Maximum number of players SourceMod supports */ diff --git a/plugins/include/cstrike.inc b/plugins/include/cstrike.inc index 556f271c..ea497b63 100644 --- a/plugins/include/cstrike.inc +++ b/plugins/include/cstrike.inc @@ -144,7 +144,7 @@ forward Action:CS_OnBuyCommand(client, const String:weapon[]); /** * Called when CSWeaponDrop is called * Return Plugin_Continue to allow the call or return a - * higher action to deny. + * higher action to block. * * @param client Client index * @param weaponIndex Weapon index diff --git a/plugins/include/dbi.inc b/plugins/include/dbi.inc index 7c2325bd..ee0876a4 100644 --- a/plugins/include/dbi.inc +++ b/plugins/include/dbi.inc @@ -477,15 +477,13 @@ stock Database SQLite_UseDatabase(const char[] database, char[] error, maxlength) { - Handle kv, db; + KeyValues kv = CreateKeyValues(""); + kv.SetString("driver", "sqlite"); + kv.SetString("database", database); - kv = CreateKeyValues(""); - KvSetString(kv, "driver", "sqlite"); - KvSetString(kv, "database", database); + Database db = SQL_ConnectCustom(kv, error, maxlength, false); - db = SQL_ConnectCustom(kv, error, maxlength, false); - - CloseHandle(kv); + delete kv; return db; } diff --git a/plugins/include/functions.inc b/plugins/include/functions.inc index ee45e5b7..b31be263 100644 --- a/plugins/include/functions.inc +++ b/plugins/include/functions.inc @@ -318,10 +318,10 @@ native Call_PushString(const String:value[]); * @param value String to push. * @param length Length of string buffer. * @param szflags Flags determining how string should be handled. - * See SP_PARAM_STRING_* constants for details. + * See SM_PARAM_STRING_* constants for details. * The default (0) is to push ASCII. * @param cpflags Whether or not changes should be copied back to the input array. - * See SP_PARAM_* constants for details. + * See SM_PARAM_* constants for details. * @noreturn * @error Called before a call has been started. */ diff --git a/plugins/include/halflife.inc b/plugins/include/halflife.inc index 4514bb08..1fe6edcd 100644 --- a/plugins/include/halflife.inc +++ b/plugins/include/halflife.inc @@ -88,6 +88,7 @@ enum EngineVersion Engine_Blade, /**< Blade Symphony */ Engine_Insurgency, /**< Insurgency (2013 Retail version)*/ Engine_Contagion, /**< Contagion */ + Engine_BlackMesa, /**< Black Mesa Multiplayer */ }; #define INVALID_ENT_REFERENCE 0xFFFFFFFF @@ -323,7 +324,7 @@ native PrintToChat(client, const String:format[], any:...); */ stock PrintToChatAll(const String:format[], any:...) { - decl String:buffer[192]; + decl String:buffer[254]; for (new i = 1; i <= MaxClients; i++) { @@ -356,7 +357,7 @@ native PrintCenterText(client, const String:format[], any:...); */ stock PrintCenterTextAll(const String:format[], any:...) { - decl String:buffer[192]; + decl String:buffer[254]; for (new i = 1; i <= MaxClients; i++) { @@ -389,7 +390,7 @@ native PrintHintText(client, const String:format[], any:...); */ stock PrintHintTextToAll(const String:format[], any:...) { - decl String:buffer[192]; + decl String:buffer[254]; for (new i = 1; i <= MaxClients; i++) { diff --git a/plugins/include/helpers.inc b/plugins/include/helpers.inc index d30c3853..ea1f915f 100644 --- a/plugins/include/helpers.inc +++ b/plugins/include/helpers.inc @@ -46,7 +46,7 @@ stock FormatUserLogText(client, String:buffer[], maxlength) { decl String:auth[32]; - decl String:name[40]; + decl String:name[MAX_NAME_LENGTH]; new userid = GetClientUserId(client); if (!GetClientAuthString(client, auth, sizeof(auth))) @@ -107,7 +107,7 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients) if (pattern[0] == '#') { int input = StringToInt(pattern[1]); if (!input) { - char name[65]; + char name[MAX_NAME_LENGTH]; for (int i=1; i<=MaxClients; i++) { if (!IsClientInGame(i)) continue; @@ -126,7 +126,7 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients) } } - char name[65]; + char name[MAX_NAME_LENGTH]; for (int i=1; i<=MaxClients; i++) { if (!IsClientInGame(i)) diff --git a/plugins/include/menus.inc b/plugins/include/menus.inc index c85b07f2..58a6a5be 100644 --- a/plugins/include/menus.inc +++ b/plugins/include/menus.inc @@ -72,7 +72,7 @@ enum MenuAction /** Default menu actions */ #define MENU_ACTIONS_DEFAULT MenuAction_Select|MenuAction_Cancel|MenuAction_End /** All menu actions */ -#define MENU_ACTIONS_ALL MenuAction:0xFFFFFFFF +#define MENU_ACTIONS_ALL view_as(0xFFFFFFFF) #define MENU_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */ #define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */ @@ -371,7 +371,7 @@ methodmap Menu < Handle int[] players = new int[MaxClients]; for (int i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || IsFakeClient(i)) - continue + continue; players[total++] = i; } return this.DisplayVote(players, total, time, flags); diff --git a/plugins/include/regex.inc b/plugins/include/regex.inc index a111dbe7..5ef8ce82 100644 --- a/plugins/include/regex.inc +++ b/plugins/include/regex.inc @@ -172,7 +172,7 @@ stock int SimpleRegexMatch(const char[] str, const char[] pattern, int flags = 0 /** * Do not edit below this line! */ -public Extension:__ext_regex = +public Extension __ext_regex = { name = "Regex Extension", file = "regex.ext", diff --git a/plugins/include/sdkhooks.inc b/plugins/include/sdkhooks.inc index 44a448a2..f936a9a8 100644 --- a/plugins/include/sdkhooks.inc +++ b/plugins/include/sdkhooks.inc @@ -299,17 +299,15 @@ typeset SDKHookCB * * @param entity Entity index * @param classname Class name - * @noreturn */ -forward OnEntityCreated(entity, const String:classname[]); +forward void OnEntityCreated(int entity, const char[] classname); /** * @brief When an entity is destroyed * * @param entity Entity index - * @noreturn */ -forward OnEntityDestroyed(entity); +forward void OnEntityDestroyed(int entity); /** * @brief When the game description is retrieved @@ -317,18 +315,18 @@ forward OnEntityDestroyed(entity); * @note Not supported on ep2v. * * @param gameDesc Game description - * @noreturn + * @return Plugin_Changed if gameDesc has been edited, else no change. */ -forward Action:OnGetGameDescription(String:gameDesc[64]); +forward Action OnGetGameDescription(char gameDesc[64]); /** * @brief When the level is initialized * * @param mapName Name of the map * @param mapEntities Entities of the map - * @noreturn + * @return Plugin_Changed if mapEntities has been edited, else no change. */ -forward Action:OnLevelInit(const String:mapName[], String:mapEntities[2097152]); +forward Action OnLevelInit(const char[] mapName, char mapEntities[2097152]); /** * @brief Hooks an entity @@ -336,9 +334,8 @@ forward Action:OnLevelInit(const String:mapName[], String:mapEntities[2097152]); * @param entity Entity index * @param type Type of function to hook * @param callback Function to call when hook is called - * @noreturn */ -native SDKHook(entity, SDKHookType:type, SDKHookCB:callback); +native void SDKHook(int entity, SDKHookType type, SDKHookCB callback); /** * @brief Hooks an entity @@ -348,7 +345,7 @@ native SDKHook(entity, SDKHookType:type, SDKHookCB:callback); * @param callback Function to call when hook is called * @return bool Hook Successful */ -native bool:SDKHookEx(entity, SDKHookType:type, SDKHookCB:callback); +native bool SDKHookEx(int entity, SDKHookType type, SDKHookCB callback); /** * @brief Unhooks an entity @@ -356,9 +353,8 @@ native bool:SDKHookEx(entity, SDKHookType:type, SDKHookCB:callback); * @param entity Entity index * @param type Type of function to unhook * @param callback Callback function to unhook - * @noreturn */ -native SDKUnhook(entity, SDKHookType:type, SDKHookCB:callback); +native void SDKUnhook(int entity, SDKHookType type, SDKHookCB callback); /** * @brief Applies damage to an entity @@ -373,9 +369,10 @@ native SDKUnhook(entity, SDKHookType:type, SDKHookCB:callback); * @param weapon Weapon index (orangebox and later) or -1 for unspecified * @param damageForce Velocity of damage force * @param damagePosition Origin of damage - * @noreturn */ -native SDKHooks_TakeDamage(entity, inflictor, attacker, Float:damage, damageType=DMG_GENERIC, weapon=-1, const Float:damageForce[3]=NULL_VECTOR, const Float:damagePosition[3]=NULL_VECTOR); +native void SDKHooks_TakeDamage(int entity, int inflictor, int attacker, + float damage, int damageType=DMG_GENERIC, int weapon=-1, + const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR); /** * @brief Forces a client to drop the specified weapon @@ -384,15 +381,15 @@ native SDKHooks_TakeDamage(entity, inflictor, attacker, Float:damage, damageType * @param weapon Weapon entity index. * @param vecTarget Location to toss weapon to, or NULL_VECTOR for default. * @param vecVelocity Velocity at which to toss weapon, or NULL_VECTOR for default. - * @noreturn * @error Invalid client or weapon entity, weapon not owned by client. */ -native SDKHooks_DropWeapon(client, weapon, const Float:vecTarget[3]=NULL_VECTOR, const Float:vecVelocity[3]=NULL_VECTOR); +native void SDKHooks_DropWeapon(int client, int weapon, const float vecTarget[3]=NULL_VECTOR, + const float vecVelocity[3]=NULL_VECTOR); /** * Do not edit below this line! */ -public Extension:__ext_sdkhooks = +public Extension __ext_sdkhooks = { name = "SDKHooks", file = "sdkhooks.ext", diff --git a/plugins/include/sdktools_functions.inc b/plugins/include/sdktools_functions.inc index fc3f9c84..ee819dfd 100644 --- a/plugins/include/sdktools_functions.inc +++ b/plugins/include/sdktools_functions.inc @@ -259,6 +259,15 @@ native SetTeamScore(index, value); */ native GetTeamClientCount(index); +/** + * Returns the entity index of a team. + * + * @param teamIndex Team index. + * @return Entity index of team. + * @error Invalid team index. + */ +native int GetTeamEntity(int teamIndex); + /** * Sets the model to a given entity. * @@ -332,6 +341,15 @@ native ActivateEntity(entity); */ native SetClientInfo(client, const String:key[], const String:value[]); +/** + * Changes a client's name. + * + * @param client Player's index. + * @param name New name. + * @error Invalid client index, or client not connected. + */ +native void SetClientName(int client, const char[] name); + /** * Gives ammo of a certain type to a player. * This natives obeys the maximum amount of ammo a player can carry per ammo type. diff --git a/plugins/include/sdktools_sound.inc b/plugins/include/sdktools_sound.inc index 12a5b7b0..2ac153d9 100644 --- a/plugins/include/sdktools_sound.inc +++ b/plugins/include/sdktools_sound.inc @@ -221,6 +221,48 @@ native EmitSound(const clients[], Float:soundtime = 0.0, any:...); +/** + * Emits a sound or game sound to a list of clients using the latest version of the engine sound interface. + * This native is only available in engines that are greater than or equal to Portal 2. + * + * @param clients Array of client indexes. + * @param numClients Number of clients in the array. + * @param soundEntry Sound entry name. + * @param sample Sound file name relative to the "sounds" folder. + * @param entity Entity to emit from. + * @param channel Channel to emit with. + * @param level Sound level. + * @param seed Sound seed. + * @param flags Sound flags. + * @param volume Sound volume. + * @param pitch Sound pitch. + * @param speakerentity Unknown. + * @param origin Sound origin. + * @param dir Sound direction. + * @param updatePos Unknown (updates positions?) + * @param soundtime Alternate time to play sound for. + * @param ... Optional list of Float[3] arrays to specify additional origins. + * @noreturn + * @error Invalid client index. + */ +native EmitSoundEntry(const clients[], + numClients, + const String:soundEntry[], + const String:sample[], + entity = SOUND_FROM_PLAYER, + channel = SNDCHAN_AUTO, + level = SNDLEVEL_NORMAL, + seed = 0, + flags = SND_NOFLAGS, + Float:volume = SNDVOL_NORMAL, + pitch = SNDPITCH_NORMAL, + speakerentity = -1, + const Float:origin[3] = NULL_VECTOR, + const Float:dir[3] = NULL_VECTOR, + bool:updatePos = true, + Float:soundtime = 0.0, + any:...); + /** * Emits a sentence to a list of clients. * @@ -307,6 +349,8 @@ typedef AmbientSHook = function Action ( * @param level Sound level. * @param pitch Sound pitch. * @param flags Sound flags. + * @param soundEntry Game sound entry name. (Used in engines newer than Portal 2) + * @param seed Sound seed. (Used in engines newer than Portal 2) * @return Plugin_Continue to allow the sound to be played, Plugin_Stop to block it, * Plugin_Changed when any parameter has been modified. */ @@ -319,7 +363,9 @@ typedef NormalSHook = function Action ( float &volume, int &level, int &pitch, - int &flags + int &flags, + char soundEntry[PLATFORM_MAX_PATH], + int &seed ); /** diff --git a/plugins/include/sdktools_tempents.inc b/plugins/include/sdktools_tempents.inc index 3cb2da61..1a711a2e 100644 --- a/plugins/include/sdktools_tempents.inc +++ b/plugins/include/sdktools_tempents.inc @@ -226,3 +226,21 @@ stock TE_SendToClient(client, Float:delay=0.0) return TE_Send(players, 1, delay); } + +/** + * Sends the current TE to all clients that are in + * visible or audible range of the origin. + * @note See TE_Start(). + * @note See GetClientsInRange() + * + * @param origin Coordinates from which to test range. + * @param rangeType Range type to use for filtering clients. + * @param delay Delay in seconds to send the TE. + * @noreturn + */ +stock TE_SendToAllInRange(float origin[3], ClientRangeType rangeType, float delay=0.0) +{ + int[] clients = new int[MaxClients]; + int total = GetClientsInRange(origin, rangeType, clients, MaxClients); + return TE_Send(clients, total, delay); +} \ No newline at end of file diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index 6c0c5b67..4dbe86cd 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -92,10 +92,6 @@ enum APLRes * If any run-time error is thrown during this callback, the plugin will be marked * as failed. * - * It is not necessary to close any handles or remove hooks in this function. - * SourceMod guarantees that plugin shutdown automatically and correctly releases - * all resources. - * * @noreturn */ forward void OnPluginStart(); @@ -132,6 +128,10 @@ forward APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) /** * Called when the plugin is about to be unloaded. * + * It is not necessary to close any handles or remove hooks in this function. + * SourceMod guarantees that plugin shutdown automatically and correctly releases + * all resources. + * * @noreturn */ forward void OnPluginEnd(); @@ -643,8 +643,7 @@ enum NumberType enum Address { - Address_Null = 0, //a typical invalid result when an address lookup fails - Address_MinimumValid = 0x10000 //addresses below this value are considered invalid to use for Load/Store + Address_Null = 0, // a typical invalid result when an address lookup fails }; /** diff --git a/plugins/include/tf2.inc b/plugins/include/tf2.inc index a98b983d..c41ab3c0 100644 --- a/plugins/include/tf2.inc +++ b/plugins/include/tf2.inc @@ -399,32 +399,26 @@ native TF2_RemoveWearable(client, wearable); * * @param client Index of the client to which the conditon is being added. * @param condition Condition that is being added. - * @noreturn */ -forward TF2_OnConditionAdded(client, TFCond:condition); +forward void TF2_OnConditionAdded(client, TFCond:condition); /** * Called after a condition is removed from a player * * @param client Index of the client to which the condition is being removed. * @param condition Condition that is being removed. - * @noreturn */ -forward TF2_OnConditionRemoved(client, TFCond:condition); +forward void TF2_OnConditionRemoved(client, TFCond:condition); /** * Called when the server enters the Waiting for Players round state - * - * @noreturn */ -forward TF2_OnWaitingForPlayersStart(); +forward void TF2_OnWaitingForPlayersStart(); /** * Called when the server exits the Waiting for Players round state - * - * @noreturn */ -forward TF2_OnWaitingForPlayersEnd(); +forward void TF2_OnWaitingForPlayersEnd(); /** * Called when a player attempts to use a teleporter to decide if the player should be allowed to teleport. diff --git a/plugins/include/tf2_stocks.inc b/plugins/include/tf2_stocks.inc index 36ffd760..21dc13b4 100644 --- a/plugins/include/tf2_stocks.inc +++ b/plugins/include/tf2_stocks.inc @@ -9,7 +9,7 @@ * 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 @@ -262,7 +262,7 @@ enum TFWeaponSlot_Building, TFWeaponSlot_PDA, TFWeaponSlot_Item1, - TFWeaponSlot_Item2 + TFWeaponSlot_Item2 }; // Identifiers for the eventtype property on the teamplay_flag_event event @@ -279,12 +279,12 @@ enum TFResourceType TFResource_Ping, TFResource_Score, TFResource_Deaths, - TFResource_TotalScore, + TFResource_TotalScore, TFResource_Captures, TFResource_Defenses, TFResource_Dominations, TFResource_Revenge, - TFResource_BuildingsDestroyed, + TFResource_BuildingsDestroyed, TFResource_Headshots, TFResource_Backstabs, TFResource_HealPoints, @@ -320,7 +320,7 @@ static const String:TFResourceNames[TFResourceType][] = /** * Gets a client's current team. - * + * * @param client Client index. * @return Current TFTeam of client. * @error Invalid client index. @@ -330,6 +330,19 @@ stock TFTeam:TF2_GetClientTeam(client) return TFTeam:GetClientTeam(client); } +/** + * Changes a client's current team. + * + * @param client Client index. + * @param team TFTeam team symbol. + * @noreturn + * @error Invalid client index. + */ +stock TF2_ChangeClientTeam(client, TFTeam:team) +{ + ChangeClientTeam(client, _:team); +} + /** * Gets a client's current class. * @@ -357,7 +370,7 @@ stock TFClassType:TF2_GetPlayerClass(client) stock TF2_SetPlayerClass(client, TFClassType:classType, bool:weapons=true, bool:persistent=true) { SetEntProp(client, Prop_Send, "m_iClass", _:classType); - + if (persistent) { SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", _:classType); @@ -377,23 +390,23 @@ stock TF2_GetPlayerResourceData(client, TFResourceType:type) { if (!IsClientConnected(client)) { - return -1; + return -1; } - + new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]); - + if (offset < 1) { - return -1; + return -1; } - + new entity = TF2_GetResourceEntity(); - + if (entity == -1) { return -1; } - + return GetEntData(entity, offset + (client*4)); } @@ -413,26 +426,26 @@ stock bool:TF2_SetPlayerResourceData(client, TFResourceType:type, any:value) { if (!IsClientConnected(client)) { - return false; + return false; } - + new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]); - + if (offset < 1) { - return false; + return false; } - + new entity = TF2_GetResourceEntity(); - + if (entity == -1) { - return false; + return false; } - + SetEntData(entity, offset + (client*4), value); - - return true; + + return true; } /** @@ -510,7 +523,7 @@ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond) { return true; } - + if ((GetEntProp(client, Prop_Send, "_condition_bits") & bit) == bit) { return true; @@ -540,7 +553,7 @@ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond) return true; } } - + return false; } @@ -554,12 +567,12 @@ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond) stock TFObjectType:TF2_GetObjectType(entity) { new offset = GetEntSendPropOffs(entity, "m_iObjectType"); - + if (offset <= 0) { ThrowError("Entity index %d is not an object", entity); } - + return TFObjectType:GetEntData(entity, offset); } @@ -573,11 +586,11 @@ stock TFObjectType:TF2_GetObjectType(entity) stock TFObjectMode:TF2_GetObjectMode(entity) { new offset = GetEntSendPropOffs(entity, "m_iObjectMode"); - + if (offset <= 0) { ThrowError("Entity index %d is not an object", entity); } - + return TFObjectMode:GetEntData(entity, offset); } diff --git a/plugins/include/timers.inc b/plugins/include/timers.inc index ba3f028f..f6b7f95c 100644 --- a/plugins/include/timers.inc +++ b/plugins/include/timers.inc @@ -96,6 +96,7 @@ native Handle:CreateTimer(Float:interval, Timer:func, any:data=INVALID_HANDLE, f * @param autoClose If autoClose is true, the data that was passed to CreateTimer() will * be closed as a handle if TIMER_DATA_HNDL_CLOSE was not specified. * @noreturn + * @error Invalid handles will cause a run time error. */ native KillTimer(Handle:timer, bool:autoClose=false); diff --git a/plugins/include/topmenus.inc b/plugins/include/topmenus.inc index 817dec51..24fd9291 100644 --- a/plugins/include/topmenus.inc +++ b/plugins/include/topmenus.inc @@ -128,7 +128,7 @@ enum TopMenuObject: * @noreturn */ typedef TopMenuHandler = function void ( - Handle topmenu, + TopMenu topmenu, TopMenuAction action, TopMenuObject topobj_id, int param, @@ -406,7 +406,7 @@ native void SetTopMenuTitleCaching(Handle topmenu, bool cache_titles); /** * Do not edit below this line! */ -public Extension:__ext_topmenus = +public Extension __ext_topmenus = { name = "TopMenus", file = "topmenus.ext", diff --git a/plugins/include/usermessages.inc b/plugins/include/usermessages.inc index d2bbfedb..7445c0b9 100644 --- a/plugins/include/usermessages.inc +++ b/plugins/include/usermessages.inc @@ -151,19 +151,39 @@ native Handle:StartMessageEx(UserMsg:msg, clients[], numClients, flags=0); native EndMessage(); /** - * Called when a message is hooked - * - * @param msg_id Message index. - * @param msg Handle to the input bit buffer or protobuf. - * @param players Array containing player indexes. - * @param playersNum Number of players in the array. - * @param reliable True if message is reliable, false otherwise. - * @param init True if message is an initmsg, false otherwise. - * @return Ignored for normal hooks. For intercept hooks, Plugin_Handled - * blocks the message from being sent, and Plugin_Continue - * resumes normal functionality. - */ -typedef MsgHook = function Action (UserMsg msg_id, Handle msg, const int[] players, int playersNum, bool reliable, bool init); + * Hook function types for user messages. +*/ +typeset MsgHook +{ + /** + * Called when a bit buffer based usermessage is hooked + * + * @param msg_id Message index. + * @param msg Handle to the input bit buffer. + * @param players Array containing player indexes. + * @param playersNum Number of players in the array. + * @param reliable True if message is reliable, false otherwise. + * @param init True if message is an initmsg, false otherwise. + * @return Ignored for normal hooks. For intercept hooks, Plugin_Handled + * blocks the message from being sent, and Plugin_Continue + * resumes normal functionality. + */ + function Action (UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init); + /** + * Called when a protobuf based usermessage is hooked + * + * @param msg_id Message index. + * @param msg Handle to the input protobuf. + * @param players Array containing player indexes. + * @param playersNum Number of players in the array. + * @param reliable True if message is reliable, false otherwise. + * @param init True if message is an initmsg, false otherwise. + * @return Ignored for normal hooks. For intercept hooks, Plugin_Handled + * blocks the message from being sent, and Plugin_Continue + * resumes normal functionality. + */ + function Action (UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init); +}; /** * Called when a message hook has completed. diff --git a/plugins/nextmap.sp b/plugins/nextmap.sp index 7135d201..ee7db53f 100644 --- a/plugins/nextmap.sp +++ b/plugins/nextmap.sp @@ -64,6 +64,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max || StrEqual(game, "garrysmod", false) || StrEqual(game, "swarm", false) || StrEqual(game, "dota", false) + || StrEqual(game, "bms", false) || GetEngineVersion() == Engine_Insurgency) { strcopy(error, err_max, "Nextmap is incompatible with this game"); diff --git a/plugins/nominations.sp b/plugins/nominations.sp index 5b0c3226..8cc305ad 100644 --- a/plugins/nominations.sp +++ b/plugins/nominations.sp @@ -234,7 +234,7 @@ public Action Command_Nominate(int client, int args) g_mapTrie.SetValue(mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED); - char name[MAX_NAME_LENGTH+1]; + char name[MAX_NAME_LENGTH]; GetClientName(client, name, sizeof(name)); PrintToChatAll("[SM] %t", "Map Nominated", name, mapname); @@ -312,8 +312,8 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p { case MenuAction_Select: { - char map[PLATFORM_MAX_PATH], name[MAX_NAME_LENGTH+1]; - menu.GetItem(param2, map, sizeof(map)); + char map[PLATFORM_MAX_PATH], name[MAX_NAME_LENGTH]; + menu.GetItem(param2, map, sizeof(map)); GetClientName(param1, name, sizeof(name)); diff --git a/plugins/playercommands.sp b/plugins/playercommands.sp index 7ddcee54..ff14b5f7 100644 --- a/plugins/playercommands.sp +++ b/plugins/playercommands.sp @@ -50,9 +50,6 @@ public Plugin:myinfo = TopMenu hTopMenu; /* Used to get the SDK / Engine version. */ -/* This is used in sm_rename and sm_changeteam */ -new EngineVersion:g_ModVersion = Engine_Unknown; - #include "playercommands/slay.sp" #include "playercommands/slap.sp" #include "playercommands/rename.sp" @@ -65,8 +62,6 @@ public OnPluginStart() RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]"); RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>"); RegAdminCmd("sm_rename", Command_Rename, ADMFLAG_SLAY, "sm_rename <#userid|name>"); - - g_ModVersion = GetEngineVersion(); /* Account for late loading */ TopMenu topmenu; diff --git a/plugins/playercommands/rename.sp b/plugins/playercommands/rename.sp index 2afd3765..5571444f 100644 --- a/plugins/playercommands/rename.sp +++ b/plugins/playercommands/rename.sp @@ -37,22 +37,8 @@ PerformRename(client, target) { LogAction(client, target, "\"%L\" renamed \"%L\" to \"%s\")", client, target, g_NewName[target]); - /* Used on OB / L4D engine */ - if (g_ModVersion != Engine_SourceSDK2006) - { - SetClientInfo(target, "name", g_NewName[target]); - } - else /* Used on CSS and EP1 / older engine */ - { - if (!IsPlayerAlive(target)) /* Lets tell them about the player renamed on the next round since they're dead. */ - { - decl String:m_TargetName[MAX_NAME_LENGTH]; + SetClientName(target, g_NewName[target]); - GetClientName(target, m_TargetName, sizeof(m_TargetName)); - ReplyToCommand(client, "[SM] %t", "Dead Player Rename", m_TargetName); - } - ClientCommand(target, "name %s", g_NewName[target]); - } g_NewName[target][0] = '\0'; } diff --git a/plugins/playercommands/slap.sp b/plugins/playercommands/slap.sp index c561f54e..8ea3f9eb 100644 --- a/plugins/playercommands/slap.sp +++ b/plugins/playercommands/slap.sp @@ -149,7 +149,7 @@ public MenuHandler_Slap(Menu menu, MenuAction action, int param1, int param2) } else { - decl String:name[32]; + decl String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformSlap(param1, target, g_SlapDamage[param1]); ShowActivity2(param1, "[SM] ", "%t", "Slapped target", "_s", name); diff --git a/plugins/playercommands/slay.sp b/plugins/playercommands/slay.sp index e5f19290..e024a698 100644 --- a/plugins/playercommands/slay.sp +++ b/plugins/playercommands/slay.sp @@ -103,7 +103,7 @@ public MenuHandler_Slay(Menu menu, MenuAction action, param1, param2) } else { - decl String:name[32]; + decl String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformSlay(param1, target); ShowActivity2(param1, "[SM] ", "%t", "Slayed target", "_s", name); diff --git a/plugins/rockthevote.sp b/plugins/rockthevote.sp index ab178e3b..fbc167ae 100644 --- a/plugins/rockthevote.sp +++ b/plugins/rockthevote.sp @@ -211,7 +211,7 @@ void AttemptRTV(int client) return; } - char name[MAX_NAME_LENGTH+1]; + new String:name[MAX_NAME_LENGTH]; GetClientName(client, name, sizeof(name)); g_Votes++; diff --git a/public/CDetour/detours.cpp b/public/CDetour/detours.cpp index f31c8c84..a82777c2 100644 --- a/public/CDetour/detours.cpp +++ b/public/CDetour/detours.cpp @@ -58,6 +58,23 @@ CDetour *CDetourManager::CreateDetour(void *callbackfunction, void **trampoline, return NULL; } +CDetour *CDetourManager::CreateDetour(void *callbackfunction, void **trampoline, void *pAddress) +{ + CDetour *detour = new CDetour(callbackfunction, trampoline, pAddress); + if (detour) + { + if (!detour->Init(spengine, gameconf)) + { + delete detour; + return NULL; + } + + return detour; + } + + return NULL; +} + CDetour::CDetour(void *callbackfunction, void **trampoline, const char *signame) { enabled = false; @@ -71,6 +88,19 @@ CDetour::CDetour(void *callbackfunction, void **trampoline, const char *signame) this->trampoline = trampoline; } +CDetour::CDetour(void*callbackfunction, void **trampoline, void *pAddress) +{ + enabled = false; + detoured = false; + detour_address = pAddress; + detour_trampoline = NULL; + this->signame = NULL; + this->detour_callback = callbackfunction; + spengine = NULL; + gameconf = NULL; + this->trampoline = trampoline; +} + bool CDetour::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf) { this->spengine = spengine; @@ -100,11 +130,16 @@ bool CDetour::IsEnabled() bool CDetour::CreateDetour() { - if (!gameconf->GetMemSig(signame, &detour_address)) + if (signame && !gameconf->GetMemSig(signame, &detour_address)) { g_pSM->LogError(myself, "Could not locate %s - Disabling detour", signame); return false; } + else if(!detour_address) + { + g_pSM->LogError(myself, "Invalid detour address passed - Disabling detour to prevent crashes"); + return false; + } if (!detour_address) { diff --git a/public/CDetour/detours.h b/public/CDetour/detours.h index db42462e..d81b177e 100644 --- a/public/CDetour/detours.h +++ b/public/CDetour/detours.h @@ -167,6 +167,7 @@ public: protected: CDetour(void *callbackfunction, void **trampoline, const char *signame); + CDetour(void*callbackfunction, void **trampoline, void *pAddress); bool Init(ISourcePawnEngine *spengine, IGameConfig *gameconf); private: @@ -239,6 +240,7 @@ public: * Note we changed the netadr_s reference into a void* to avoid needing to define the type */ static CDetour *CreateDetour(void *callbackfunction, void **trampoline, const char *signame); + static CDetour *CreateDetour(void *callbackfunction, void **trampoline, void *pAddress); friend class CBlocker; friend class CDetour; diff --git a/public/IForwardSys.h b/public/IForwardSys.h index 577c1ea7..3ea98739 100644 --- a/public/IForwardSys.h +++ b/public/IForwardSys.h @@ -171,7 +171,7 @@ namespace SourceMod * @param filter Do not use. * @return Error code, if any. */ - virtual int Execute(cell_t *result, IForwardFilter *filter=NULL) =0; + virtual int Execute(cell_t *result=NULL, IForwardFilter *filter=NULL) =0; /** * @brief Pushes an array of cells onto the current call. Different rules than ICallable. diff --git a/public/INativeInvoker.h b/public/INativeInvoker.h deleted file mode 100644 index 91429308..00000000 --- a/public/INativeInvoker.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * vim: set ts=4 : - * ============================================================================= - * SourceMod - * Copyright (C) 2004-2009 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEMOD_INATIVEINVOKER_H_ -#define _INCLUDE_SOURCEMOD_INATIVEINVOKER_H_ - -/** - * @file INativeInvoker.h - * @brief Interface for invoking natives. - */ - -#include -#include - -#define SMINTERFACE_NINVOKE_NAME "INativeInterface" -#define SMINTERFACE_NINVOKE_VERSION 1 - -#define NINVOKE_DEFAULT_MEMORY 16384 - -namespace SourceMod -{ - class INativeInvoker : public SourcePawn::ICallable - { - public: - /** - * @brief Virtual destructor - use delete to free this. - */ - virtual ~INativeInvoker() - { - } - public: - /** - * @brief Begins a native call. - * - * During a call's preparation, no new calls may be started. - * - * @param pContext Context to invoke native under. - * @param name Name of native. - * @return True if native was found, false otherwise. - */ - virtual bool Start(SourcePawn::IPluginContext *pContext, const char *name) = 0; - - /** - * @brief Invokes the native. The preparation state is cleared immediately, meaning that - * this object can be re-used after or even from inside the native being called. - * - * @param result Optional pointer to retrieve a result. - * @return SP_ERROR return code. - */ - virtual int Invoke(cell_t *result) = 0; - }; - - /** - * @brief Factory for dealing with native invocations. - */ - class INativeInterface : public SMInterface - { - public: - /** - * @brief Creates a virtual plugin. This can be used as an environment to invoke natives. - * - * IPluginRuntime objects must be freed with the delete operator. - * - * @param name Name, or NULL for anonymous. - * @param bytes Number of bytes for memory (NINVOKE_DEFAULT_MEMORY recommended). - * @return New runtime, or NULL on failure. - */ - virtual SourcePawn::IPluginRuntime *CreateRuntime(const char *name, size_t bytes) = 0; - - /** - * @brief Creates an object that can be used to invoke a single native code. - * - * @return New native invoker (free with delete). - */ - virtual INativeInvoker *CreateInvoker() = 0; - }; -} - -#endif /* _INCLUDE_SOURCEMOD_INATIVEINVOKER_H_ */ diff --git a/public/amtl b/public/amtl new file mode 160000 index 00000000..9b1cb728 --- /dev/null +++ b/public/amtl @@ -0,0 +1 @@ +Subproject commit 9b1cb728c931c0b42a23b96a3c0909470769a72f diff --git a/public/amtl/am-allocator-policies.h b/public/amtl/am-allocator-policies.h deleted file mode 100644 index 5f9712bf..00000000 --- a/public/amtl/am-allocator-policies.h +++ /dev/null @@ -1,65 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_allocatorpolicies_h_ -#define _include_amtl_allocatorpolicies_h_ - -#include -#include - -namespace ke { - -// The default system allocator policy will crash on out-of-memory. -class SystemAllocatorPolicy -{ - public: - void reportOutOfMemory() { - fprintf(stderr, "OUT OF MEMORY\n"); - abort(); - } - void reportAllocationOverflow() { - fprintf(stderr, "OUT OF MEMORY\n"); - abort(); - } - - public: - void free(void *memory) { - ::free(memory); - } - void *malloc(size_t bytes) { - void *ptr = ::malloc(bytes); - if (!ptr) - reportOutOfMemory(); - return ptr; - } -}; - -} - -#endif // _include_amtl_allocatorpolicies_h_ diff --git a/public/amtl/am-atomics.h b/public/amtl/am-atomics.h deleted file mode 100644 index e32d1df9..00000000 --- a/public/amtl/am-atomics.h +++ /dev/null @@ -1,102 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_atomics_h_ -#define _include_amtl_atomics_h_ - -#include - -namespace ke { - -#if defined(_MSC_VER) -extern "C" { - long __cdecl _InterlockedIncrement(long volatile *dest); - long __cdecl _InterlockedDecrement(long volatile *dest); -} -# pragma intrinsic(_InterlockedIncrement) -# pragma intrinsic(_InterlockedDecrement) -#endif - -template -struct AtomicOps; - -template <> -struct AtomicOps<4> -{ -#if defined(_MSC_VER) - typedef long Type; - - static Type Increment(Type *ptr) { - return _InterlockedIncrement(ptr); - } - static Type Decrement(Type *ptr) { - return _InterlockedDecrement(ptr); - }; -#elif defined(__GNUC__) - typedef int Type; - - // x86/x64 notes: When using GCC < 4.8, this will compile to a spinlock. - // On 4.8+, or when using Clang, we'll get the more optimal "lock addl" - // variant. - static Type Increment(Type *ptr) { - return __sync_add_and_fetch(ptr, 1); - } - static Type Decrement(Type *ptr) { - return __sync_sub_and_fetch(ptr, 1); - } -#endif -}; - -class AtomicRefCount -{ - typedef AtomicOps Ops; - - public: - AtomicRefCount(uintptr_t value) - : value_(value) - { - } - - void increment() { - Ops::Increment(&value_); - } - - // Return false if all references are gone. - bool decrement() { - return Ops::Decrement(&value_) != 0; - } - - private: - Ops::Type value_; -}; - -} - -#endif // _include_amtl_atomics_h_ - diff --git a/public/amtl/am-fixedarray.h b/public/amtl/am-fixedarray.h deleted file mode 100644 index 4681651d..00000000 --- a/public/amtl/am-fixedarray.h +++ /dev/null @@ -1,99 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013-2014, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -#ifndef _include_amtl_fixedarray_h_ -#define _include_amtl_fixedarray_h_ - -#include -#include -#include - -namespace ke { - -template -class FixedArray : public AllocPolicy -{ - public: - FixedArray(size_t length, AllocPolicy = AllocPolicy()) { - length_ = length; - data_ = (T *)this->malloc(sizeof(T) * length_); - if (!data_) - return; - - for (size_t i = 0; i < length_; i++) - new (&data_[i]) T(); - } - ~FixedArray() { - for (size_t i = 0; i < length_; i++) - data_[i].~T(); - this->free(data_); - } - - // This call may be skipped if the allocator policy is infallible. - bool initialize() { - return length_ == 0 || !!data_; - } - - size_t length() const { - return length_; - } - T &operator [](size_t index) { - return at(index); - } - const T &operator [](size_t index) const { - return at(index); - } - T &at(size_t index) { - assert(index < length()); - return data_[index]; - } - const T &at(size_t index) const { - assert(index < length()); - return data_[index]; - } - void set(size_t index, const T &t) { - assert(index < length()); - data_[index] = t; - } - void set(size_t index, ke::Moveable t) { - assert(index < length()); - data_[index] = t; - } - - private: - FixedArray(const FixedArray &other) KE_DELETE; - FixedArray &operator =(const FixedArray &other) KE_DELETE; - - private: - size_t length_; - T *data_; -}; - -} // namespace ke - -#endif // _include_amtl_fixedarray_h_ diff --git a/public/amtl/am-float.h b/public/amtl/am-float.h deleted file mode 100644 index e53f25a0..00000000 --- a/public/amtl/am-float.h +++ /dev/null @@ -1,50 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_float_h_ -#define _include_amtl_float_h_ - -#include -#include - -namespace ke { - -static inline bool -IsNaN(double v) -{ -#ifdef _MSC_VER - return !!_isnan(v); -#else - return isnan(v); -#endif -} - -} // namespace ke - -#endif // _include_amtl_float_h_ diff --git a/public/amtl/am-hashmap.h b/public/amtl/am-hashmap.h deleted file mode 100644 index 7d5c3839..00000000 --- a/public/amtl/am-hashmap.h +++ /dev/null @@ -1,201 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_hashmap_h_ -#define _include_amtl_hashmap_h_ - -#include - -namespace ke { - -// Template parameters: -// -// K - Key type. -// V - Value type. -// HashPolicy - A struct with a hash and comparator function for each lookup type: -// static uint32_t hash(const Type &value); -// static bool matches(const Type &value, const K &key); -// -// All types that match a given key, must compute the same hash. -// -// Note that like HashTable, a HashMap is not usable until init() has been called. -template -class HashMap : public AllocPolicy -{ - private: - struct Entry - { - K key; - V value; - - Entry() - { - } - Entry(Moveable other) - : key(Moveable(other->key)), - value(Moveable(other->value)) - { - } - - Entry(const K &aKey, const V &aValue) - : key(aKey), - value(aValue) - { } - Entry(const K &aKey, Moveable aValue) - : key(aKey), - value(aValue) - { } - Entry(Moveable aKey, const V &aValue) - : key(aKey), - value(aValue) - { } - Entry(Moveable aKey, Moveable aValue) - : key(aKey), - value(aValue) - { } - }; - - struct Policy - { - typedef Entry Payload; - - template - static uint32_t hash(const Lookup &key) { - return HashPolicy::hash(key); - } - - template - static bool matches(const Lookup &key, const Payload &payload) { - return HashPolicy::matches(key, payload.key); - } - }; - - typedef HashTable Internal; - - public: - HashMap(AllocPolicy ap = AllocPolicy()) - : table_(ap) - { - } - - // capacity must be a power of two. - bool init(size_t capacity = 16) { - return table_.init(capacity); - } - - typedef typename Internal::Result Result; - typedef typename Internal::Insert Insert; - typedef typename Internal::iterator iterator; - - template - Result find(const Lookup &key) { - return table_.find(key); - } - - template - Insert findForAdd(const Lookup &key) { - return table_.findForAdd(key); - } - - template - void removeIfExists(const Lookup &key) { - return table_.remove(key); - } - - void remove(Result &r) { - table_.remove(r); - } - - // The map must not have been mutated in between findForAdd() and add(). - // The Insert object is still valid after add() returns, however. - bool add(Insert &i, const K &key, const V &value) { - Entry entry(key, value); - return table_.add(i, ke::Move(entry)); - } - bool add(Insert &i, Moveable key, const V &value) { - Entry entry(key, value); - return table_.add(i, ke::Move(entry)); - } - bool add(Insert &i, const K &key, Moveable value) { - Entry entry(key, value); - return table_.add(i, ke::Move(entry)); - } - bool add(Insert &i, Moveable key, Moveable value) { - Entry entry(key, value); - return table_.add(i, ke::Move(entry)); - } - bool add(Insert &i, Moveable key) { - Entry entry(key, V()); - return table_.add(i, ke::Move(entry)); - } - - // This can be used to avoid compiler constructed temporaries, since AMTL - // does not yet support move semantics. If you use this, the key and value - // must be set after. - bool add(Insert &i) { - return table_.add(i); - } - - iterator iter() { - return iterator(&table_); - } - - void clear() { - table_.clear(); - } - - size_t elements() const { - return table_.elements(); - } - - size_t estimateMemoryUse() const { - return table_.estimateMemoryUse(); - } - - private: - Internal table_; -}; - -template -struct PointerPolicy -{ - static inline uint32_t hash(T *p) { - return HashPointer(p); - } - static inline bool matches(T *p1, T *p2) { - return p1 == p2; - } -}; - -} - -#endif // _include_amtl_hashmap_h_ diff --git a/public/amtl/am-hashset.h b/public/amtl/am-hashset.h deleted file mode 100644 index 13f8eb8f..00000000 --- a/public/amtl/am-hashset.h +++ /dev/null @@ -1,129 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_hashmap_h_ -#define _include_amtl_hashmap_h_ - -#include - -namespace ke { - -// Template parameters: -// -// K - Key type. -// HashPolicy - A struct with a hash and comparator function for each lookup type: -// static uint32_t hash(const Type &value); -// static bool matches(const Type &value, const K &key); -// -// Like HashMap and HashTable, init() must be called to construct the set. -template -class HashSet : public AllocPolicy -{ - struct Policy { - typedef K Payload; - - template - static uint32_t hash(const Lookup &key) { - return HashPolicy::hash(key); - } - - template - static bool matches(const Lookup &key, const Payload &payload) { - return HashPolicy::matches(key, payload); - } - }; - - typedef HashTable Internal; - - public: - HashSet(AllocPolicy ap = AllocPolicy()) - : table_(ap) - { - } - - // capacity must be a power of two. - bool init(size_t capacity = 16) { - return table_.init(capacity); - } - - typedef typename Internal::Result Result; - typedef typename Internal::Insert Insert; - - template - Result find(const Lookup &key) { - return table_.find(key); - } - - template - Insert findForAdd(const Lookup &key) { - return table_.findForAdd(key); - } - - template - void removeIfExists(const Lookup &key) { - return table_.remove(key); - } - - void remove(Result &r) { - table_.remove(r); - } - - // The map must not have been mutated in between findForAdd() and add(). - // The Insert object is still valid after add() returns, however. - bool add(Insert &i, const K &key) { - return table_.add(i, key); - } - bool add(Insert &i, Moveable key) { - return table_.add(i, key); - } - - // This can be used to avoid compiler constructed temporaries, since AMTL - // does not yet support move semantics. If you use this, the key and value - // must be set after. - bool add(Insert &i) { - return table_.add(i); - } - - void clear() { - table_.clear(); - } - - size_t estimateMemoryUse() const { - return table_.estimateMemoryUse(); - } - - private: - Internal table_; -}; - -} - -#endif // _include_amtl_hashset_h_ diff --git a/public/amtl/am-hashtable.h b/public/amtl/am-hashtable.h deleted file mode 100644 index 1101a247..00000000 --- a/public/amtl/am-hashtable.h +++ /dev/null @@ -1,631 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _INCLUDE_KEIMA_HASHTABLE_H_ -#define _INCLUDE_KEIMA_HASHTABLE_H_ - -#include -#include -#include -#include "am-allocator-policies.h" -#include "am-utility.h" -#include "am-moveable.h" - -namespace ke { - -namespace detail { - template - class HashTableEntry - { - uint32_t hash_; - T t_; - - public: - static const uint32_t kFreeHash = 0; - static const uint32_t kRemovedHash = 1; - - public: - void setHash(uint32_t hash) { - hash_ = hash; - } - void construct() { - new (&t_) T(); - } - void construct(const T &t) { - new (&t_) T(t); - } - void construct(Moveable t) { - new (&t_) T(t); - } - uint32_t hash() const { - return hash_; - } - void setRemoved() { - destruct(); - hash_ = kRemovedHash; - } - void setFree() { - destruct(); - hash_ = kFreeHash; - } - void initialize() { - hash_ = kFreeHash; - } - void destruct() { - if (isLive()) - t_.~T(); - } - bool removed() const { - return hash_ == kRemovedHash; - } - bool free() const { - return hash_ == kFreeHash; - } - bool isLive() const { - return hash_ > kRemovedHash; - } - T &payload() { - assert(isLive()); - return t_; - } - bool sameHash(uint32_t hash) const { - return hash_ == hash; - } - - private: - HashTableEntry(const HashTableEntry &other) KE_DELETE; - HashTableEntry &operator =(const HashTableEntry &other) KE_DELETE; - }; -} - -// The HashPolicy for the table must have the following members: -// -// Payload -// static uint32_t hash(const LookupType &key); -// static bool matches(const LookupType &key, const Payload &other); -// -// Payload must be a type, and LookupType is any type that lookups will be -// performed with (these functions can be overloaded). Example: -// -// struct Policy { -// typedef KeyValuePair Payload; -// static uint32 hash(const Key &key) { -// ... -// } -// static bool matches(const Key &key, const KeyValuePair &pair) { -// ... -// } -// }; -// -// Note that the table is not usable until init() has been called. -// -template -class HashTable : public AllocPolicy -{ - friend class iterator; - - typedef typename HashPolicy::Payload Payload; - typedef detail::HashTableEntry Entry; - - private: - static const uint32_t kMinCapacity = 16; - static const uint32_t kMaxCapacity = INT_MAX / sizeof(Entry); - - template - uint32_t computeHash(const Key &key) { - // Multiply by golden ratio. - uint32_t hash = HashPolicy::hash(key) * 0x9E3779B9; - if (hash == Entry::kFreeHash || hash == Entry::kRemovedHash) - hash += 2; - return hash; - } - - Entry *createTable(uint32_t capacity) { - assert(capacity <= kMaxCapacity); - - Entry *table = (Entry *)this->malloc(capacity * sizeof(Entry)); - if (!table) - return NULL; - - for (size_t i = 0; i < capacity; i++) - table[i].initialize(); - - return table; - } - - public: - class Result - { - friend class HashTable; - - Entry *entry_; - - Entry &entry() { - return *entry_; - } - - public: - Result(Entry *entry) - : entry_(entry) - { } - - Payload * operator ->() { - return &entry_->payload(); - } - Payload & operator *() { - return entry_->payload(); - } - - bool found() const { - return entry_->isLive(); - } - }; - - class Insert : public Result - { - uint32_t hash_; - - public: - Insert(Entry *entry, uint32_t hash) - : Result(entry), - hash_(hash) - { - } - - uint32_t hash() const { - return hash_; - } - }; - - private: - class Probulator { - uint32_t hash_; - uint32_t capacity_; - - public: - Probulator(uint32_t hash, uint32_t capacity) - : hash_(hash), - capacity_(capacity) - { - assert(IsPowerOfTwo(capacity_)); - } - - uint32_t entry() const { - return hash_ & (capacity_ - 1); - } - uint32_t next() { - hash_++; - return entry(); - } - }; - - bool underloaded() const { - // Check if the table is underloaded: < 25% entries used. - return (capacity_ > kMinCapacity) && (nelements_ + ndeleted_ < capacity_ / 4); - } - bool overloaded() const { - // Grow if the table is overloaded: > 75% entries used. - return (nelements_ + ndeleted_) > ((capacity_ / 2) + (capacity_ / 4)); - } - - bool shrink() { - if ((capacity_ >> 1) < minCapacity_) - return true; - return changeCapacity(capacity_ >> 1); - } - - bool grow() { - if (capacity_ >= kMaxCapacity) { - this->reportAllocationOverflow(); - return false; - } - return changeCapacity(capacity_ << 1); - } - - bool changeCapacity(uint32_t newCapacity) { - assert(newCapacity <= kMaxCapacity); - - Entry *newTable = createTable(newCapacity); - if (!newTable) - return false; - - Entry *oldTable = table_; - uint32_t oldCapacity = capacity_; - - table_ = newTable; - capacity_ = newCapacity; - ndeleted_ = 0; - - for (uint32_t i = 0; i < oldCapacity; i++) { - Entry &oldEntry = oldTable[i]; - if (oldEntry.isLive()) { - Insert p = insertUnique(oldEntry.hash()); - p.entry().setHash(p.hash()); - p.entry().construct(Moveable(oldEntry.payload())); - } - oldEntry.destruct(); - } - this->free(oldTable); - - return true; - } - - // For use when the key is known to be unique. - Insert insertUnique(uint32_t hash) { - Probulator probulator(hash, capacity_); - - Entry *e = &table_[probulator.entry()]; - for (;;) { - if (e->free() || e->removed()) - break; - e = &table_[probulator.next()]; - } - - return Insert(e, hash); - } - - template - Result lookup(const Key &key) { - uint32_t hash = computeHash(key); - Probulator probulator(hash, capacity_); - - Entry *e = &table_[probulator.entry()]; - for (;;) { - if (e->free()) - break; - if (e->isLive() && - e->sameHash(hash) && - HashPolicy::matches(key, e->payload())) - { - return Result(e); - } - e = &table_[probulator.next()]; - } - - return Result(e); - } - - template - Insert lookupForAdd(const Key &key) { - uint32_t hash = computeHash(key); - Probulator probulator(hash, capacity_); - - Entry *e = &table_[probulator.entry()]; - for (;;) { - if (!e->isLive()) - break; - if (e->sameHash(hash) && HashPolicy::matches(key, e->payload())) - break; - e = &table_[probulator.next()]; - } - - return Insert(e, hash); - } - - bool internalAdd(Insert &i) { - assert(!i.found()); - - // If the entry is deleted, just re-use the slot. - if (i.entry().removed()) { - ndeleted_--; - } else { - // Otherwise, see if we're at max capacity. - if (nelements_ == kMaxCapacity) { - this->reportAllocationOverflow(); - return false; - } - - // Check if the table is over or underloaded. The table is always at - // least 25% free, so this check is enough to guarantee one free slot. - // (Without one free slot, insertion search could infinite loop.) - uint32_t oldCapacity = capacity_; - if (!checkDensity()) - return false; - - // If the table changed size, we need to find a new insertion point. - // Note that a removed entry is impossible: either we caught it above, - // or we just resized and no entries are removed. - if (capacity_ != oldCapacity) - i = insertUnique(i.hash()); - } - - nelements_++; - i.entry().setHash(i.hash()); - return true; - } - - void removeEntry(Entry &e) { - assert(e.isLive()); - e.setRemoved(); - ndeleted_++; - nelements_--; - } - - public: - HashTable(AllocPolicy ap = AllocPolicy()) - : AllocPolicy(ap), - capacity_(0), - nelements_(0), - ndeleted_(0), - table_(NULL), - minCapacity_(kMinCapacity) - { - } - - ~HashTable() - { - for (uint32_t i = 0; i < capacity_; i++) - table_[i].destruct(); - this->free(table_); - } - - bool init(uint32_t capacity = 0) { - if (capacity < kMinCapacity) { - capacity = kMinCapacity; - } else if (capacity > kMaxCapacity) { - this->reportAllocationOverflow(); - return false; - } - - minCapacity_ = capacity; - - assert(IsPowerOfTwo(capacity)); - capacity_ = capacity; - - table_ = createTable(capacity_); - if (!table_) - return false; - - return true; - } - - // The Result object must not be used past mutating table operations. - template - Result find(const Key &key) { - return lookup(key); - } - - // The Insert object must not be used past mutating table operations. - template - Insert findForAdd(const Key &key) { - return lookupForAdd(key); - } - - template - void removeIfExists(const Key &key) { - Result r = find(key); - if (!r.found()) - return; - remove(r); - } - - void remove(Result &r) { - assert(r.found()); - removeEntry(r.entry()); - } - - // The table must not have been mutated in between findForAdd() and add(). - // The Insert object is still valid after add() returns, however. - bool add(Insert &i, const Payload &payload) { - if (!internalAdd(i)) - return false; - i.entry().construct(payload); - return true; - } - bool add(Insert &i, Moveable payload) { - if (!internalAdd(i)) - return false; - i.entry().construct(payload); - return true; - } - bool add(Insert &i) { - if (!internalAdd(i)) - return false; - i.entry().construct(); - return true; - } - - bool checkDensity() { - if (underloaded()) - return shrink(); - if (overloaded()) - return grow(); - return true; - } - - void clear() { - for (size_t i = 0; i < capacity_; i++) { - table_[i].setFree(); - } - ndeleted_ = 0; - nelements_ = 0; - } - - size_t elements() const { - return nelements_; - } - - size_t estimateMemoryUse() const { - return sizeof(Entry) * capacity_; - } - - public: - // It is illegal to mutate a HashTable during iteration. - class iterator - { - public: - iterator(HashTable *table) - : table_(table), - i_(table->table_), - end_(table->table_ + table->capacity_) - { - while (i_ < end_ && !i_->isLive()) - i_++; - } - - bool empty() const { - return i_ == end_; - } - - void erase() { - assert(!empty()); - table_->removeEntry(*i_); - } - - Payload *operator ->() const { - return &i_->payload(); - } - Payload &operator *() const { - return i_->payload(); - } - - void next() { - do { - i_++; - } while (i_ < end_ && !i_->isLive()); - } - - private: - HashTable *table_; - Entry *i_; - Entry *end_; - }; - - private: - HashTable(const HashTable &other) KE_DELETE; - HashTable &operator =(const HashTable &other) KE_DELETE; - - private: - uint32_t capacity_; - uint32_t nelements_; - uint32_t ndeleted_; - Entry *table_; - uint32_t minCapacity_; -}; - -// Bob Jenkin's one-at-a-time hash function[1]. -// -// [1] http://burtleburtle.net/bob/hash/doobs.html -class CharacterStreamHasher -{ - uint32_t hash; - - public: - CharacterStreamHasher() - : hash(0) - { } - - void add(char c) { - hash += c; - hash += (hash << 10); - hash ^= (hash >> 6); - } - - void add(const char *s, size_t length) { - for (size_t i = 0; i < length; i++) - add(s[i]); - } - - uint32_t result() { - hash += (hash << 3); - hash ^= (hash >> 11); - hash += (hash << 15); - return hash; - } -}; - -static inline uint32_t -HashCharSequence(const char *s, size_t length) -{ - CharacterStreamHasher hasher; - hasher.add(s, length); - return hasher.result(); -} - -static inline uint32_t -FastHashCharSequence(const char *s, size_t length) -{ - uint32_t hash = 0; - for (size_t i = 0; i < length; i++) - hash = s[i] + (hash << 6) + (hash << 16) - hash; - return hash; -} - -// From http://burtleburtle.net/bob/hash/integer.html -static inline uint32_t -HashInt32(int32_t a) -{ - a = (a ^ 61) ^ (a >> 16); - a = a + (a << 3); - a = a ^ (a >> 4); - a = a * 0x27d4eb2d; - a = a ^ (a >> 15); - return a; -} - -// From http://www.cris.com/~Ttwang/tech/inthash.htm -static inline uint32_t -HashInt64(int64_t key) -{ - key = (~key) + (key << 18); // key = (key << 18) - key - 1; - key = key ^ (uint64_t(key) >> 31); - key = key * 21; // key = (key + (key << 2)) + (key << 4); - key = key ^ (uint64_t(key) >> 11); - key = key + (key << 6); - key = key ^ (uint64_t(key) >> 22); - return uint32_t(key); -} - -template -static inline uint32_t -HashInteger(uintptr_t value); - -template <> -inline uint32_t -HashInteger<4>(uintptr_t value) -{ - return HashInt32(value); -} - -template <> -inline uint32_t -HashInteger<8>(uintptr_t value) -{ - return HashInt64(value); -} - -static inline uint32_t -HashPointer(void *ptr) -{ - return HashInteger(reinterpret_cast(ptr)); -} - -} // namespace ke - -#endif // _INCLUDE_KEIMA_HASHTABLE_H_ diff --git a/public/amtl/am-inlinelist.h b/public/amtl/am-inlinelist.h deleted file mode 100644 index 99c37793..00000000 --- a/public/amtl/am-inlinelist.h +++ /dev/null @@ -1,183 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_inline_list_h_ -#define _include_amtl_inline_list_h_ - -#include -#include - -namespace ke { - -template class InlineList; - -// Objects can recursively inherit from InlineListNode in order to have -// membership in an InlineList. -template -class InlineListNode -{ - friend class InlineList; - - public: - InlineListNode() - : next_(NULL), - prev_(NULL) - { - } - - InlineListNode(InlineListNode *next, InlineListNode *prev) - : next_(next), - prev_(prev) - { - } - - protected: - InlineListNode *next_; - InlineListNode *prev_; -}; - -// An InlineList is a linked list that threads link pointers through objects, -// rather than allocating node memory. A node can be in at most one list at -// any time. -// -// Since InlineLists are designed to be very cheap, there is no requirement -// that elements be removed from a list once the list is destructed. However, -// for as long as the list is alive, all of its contained nodes must also -// be alive. -template -class InlineList -{ - typedef InlineListNode Node; - - Node head_; - - // Work around a clang bug where we can't initialize with &head_ in the ctor. - inline Node *head() { - return &head_; - } - - public: - InlineList() - : head_(head(), head()) - { - } - - ~InlineList() - { -#if !defined(NDEBUG) - // Remove all items to clear their next/prev fields. - while (begin() != end()) - remove(*begin()); -#endif - } - - public: - class iterator - { - friend class InlineList; - Node *iter_; - - public: - iterator(Node *iter) - : iter_(iter) - { - } - - iterator & operator ++() { - iter_ = iter_->next; - return *this; - } - iterator operator ++(int) { - iterator old(*this); - iter_ = iter_->next_; - return old; - } - T * operator *() { - return static_cast(iter_); - } - T * operator ->() { - return static_cast(iter_); - } - bool operator !=(const iterator &where) const { - return iter_ != where.iter_; - } - bool operator ==(const iterator &where) const { - return iter_ == where.iter_; - } - }; - - iterator begin() { - return iterator(head_.next_); - } - - iterator end() { - return iterator(&head_); - } - - iterator erase(iterator &at) { - iterator next = at; - next++; - - remove(at.iter_); - - // Iterator is no longer valid. - at.iter_ = NULL; - - return next; - } - - bool empty() const { - return head_.next_ == &head_; - } - - void remove(Node *t) { - t->prev_->next_ = t->next_; - t->next_->prev_ = t->prev_; - -#if !defined(NDEBUG) - t->next_ = NULL; - t->prev_ = NULL; -#endif - } - - void append(Node *t) { - assert(!t->next_); - assert(!t->prev_); - - t->prev_ = head_.prev_; - t->next_ = &head_; - head_.prev_->next_ = t; - head_.prev_ = t; - } -}; - -} - -#endif // _include_amtl_inline_list_h_ - diff --git a/public/amtl/am-linkedlist.h b/public/amtl/am-linkedlist.h deleted file mode 100644 index 488e97a2..00000000 --- a/public/amtl/am-linkedlist.h +++ /dev/null @@ -1,309 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_linkedlist_h_ -#define _include_amtl_linkedlist_h_ - -#include -#include -#include -#include -#include - -namespace ke { - -// LinkedList, analagous to std::list or SourceHook::List. Since it performs a -// malloc() and free() on every contained node, it should be avoided unless -// absolutely necessary, or for when allocation performance is not a factor. It -// is provided here to safely port old AlliedModders code to AMTL. -// -// In order to use a circular chain, LinkedList's allocation size includes -// exactly one T. If T is very large, LinkedList should be allocated on the -// heap, to avoid using the stack. -template -class LinkedList : public AllocPolicy -{ - public: - friend class iterator; - - class Node - { - public: - Node(const T &o) - : obj(o) - { - } - Node(Moveable o) - : obj(o) - { - } - - T obj; - Node *next; - Node *prev; - }; - -public: - LinkedList(AllocPolicy = AllocPolicy()) - : length_(0) - { - head()->prev = head(); - head()->next = head(); - } - ~LinkedList() { - clear(); - } - - bool append(const T &obj) { - return insertBefore(end(), obj) != end(); - } - bool append(Moveable obj) { - return insertBefore(end(), obj) != end(); - } - - bool prepend(const T &obj) { - return insertBefore(begin(), obj) != begin(); - } - bool prepend(Moveable obj) { - return insertBefore(begin(), obj) != begin(); - } - - size_t length() const { - return length_; - } - - void clear() { - Node *node = head()->next; - Node *temp; - head()->next = head(); - head()->prev = head(); - - // Iterate through the nodes until we find the sentinel again. - while (node != head()) { - temp = node->next; - freeNode(node); - node = temp; - } - length_ = 0; - } - - bool empty() const { - return (length_ == 0); - } - - T &front() { - assert(!empty()); - return head()->next->obj; - } - T &back() { - assert(!empty()); - return head()->prev->obj; - } - - private: - const Node *head() const { - return sentinel_.address(); - } - Node *head() { - return sentinel_.address(); - } - - Node *allocNode(const T &obj) { - Node *node = (Node *)this->malloc(sizeof(Node)); - if (!node) - return NULL; - new (node) Node(obj); - return node; - } - Node *allocNode(Moveable obj) { - Node *node = (Node *)this->malloc(sizeof(Node)); - if (!node) - return NULL; - new (node) Node(obj); - return node; - } - - void freeNode(Node *node) { - node->obj.~T(); - this->free(node); - } - - private: - StorageBuffer sentinel_; - size_t length_; - - public: - class iterator - { - friend class LinkedList; - - public: - iterator() - : this_(NULL) - { - } - iterator(const LinkedList &src) - : this_(src.head()) - { - } - iterator(Node *n) - : this_(n) - { - } - iterator(const iterator &where) - : this_(where.this_) - { - } - - iterator &operator --() { - if (this_) - this_ = this_->prev; - return *this; - } - iterator operator --(int) { - iterator old(*this); - if (this_) - this_ = this_->prev; - return old; - } - iterator &operator ++() { - if (this_) - this_ = this_->next; - return *this; - } - iterator operator ++(int) { - iterator old(*this); - if (this_) - this_ = this_->next; - return old; - } - - const T &operator * () const { - return this_->obj; - } - T &operator * () { - return this_->obj; - } - T *operator ->() { - return &this_->obj; - } - const T *operator ->() const { - return &(this_->obj); - } - - bool operator !=(const iterator &where) const { - return (this_ != where.this_); - } - bool operator ==(const iterator &where) const { - return (this_ == where.this_); - } - - operator bool() { - return !!this_; - } - - private: - Node *this_; - }; - - private: - // Insert obj right before where. - iterator insert(iterator where, Node *node) { - if (!node) - return where; - - Node *pWhereNode = where.this_; - - pWhereNode->prev->next = node; - node->prev = pWhereNode->prev; - pWhereNode->prev = node; - node->next = pWhereNode; - - length_++; - return iterator(node); - } - - public: - iterator begin() { - return iterator(head()->next); - } - iterator end() { - return iterator(head()); - } - iterator erase(iterator where) { - Node *pNode = where.this_; - iterator iter(where); - iter++; - - pNode->prev->next = pNode->next; - pNode->next->prev = pNode->prev; - - freeNode(pNode); - length_--; - - return iter; - } - iterator insertBefore(iterator where, const T &obj) { - return insert(where, allocNode(obj)); - } - iterator insertBefore(iterator where, Moveable obj) { - return insert(where, allocNode(obj)); - } - - public: - // Removes one instance of |obj| from the list, if found. - void remove(const T &obj) { - for (iterator b = begin(); b != end(); b++) { - if (*b == obj) { - erase(b); - break; - } - } - } - - template - iterator find(const U &equ) { - for (iterator iter = begin(); iter != end(); iter++) { - if (*iter == equ) - return iter; - } - return end(); - } - - - private: - // These are disallowed because they basically violate the failure handling - // model for AllocPolicies and are also likely to have abysmal performance. - LinkedList &operator =(const LinkedList &other) KE_DELETE; - LinkedList(const LinkedList &other) KE_DELETE; -}; - -} // namespace ke - -#endif //_INCLUDE_CSDM_LIST_H diff --git a/public/amtl/am-moveable.h b/public/amtl/am-moveable.h deleted file mode 100644 index e500dbc7..00000000 --- a/public/amtl/am-moveable.h +++ /dev/null @@ -1,73 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_moveable_h_ -#define _include_amtl_moveable_h_ - -namespace ke { - -// This is a feature in C++11, but since AM projects do not have access to -// C++11 yet, we provide templates to implement move semantics. A class can -// provide a constructor for (ke::Moveable t) which containers will try -// to use. -// -// When implementing a constructor that takes a Moveable, the object being -// moved should be left in a state that is safe, since its destructor will -// be called even though it has been moved. - -template -struct Moveable -{ - public: - explicit Moveable(T &t) - : t_(t) - { - } - - T *operator ->() { - return &t_; - } - operator T &() { - return t_; - } - - private: - T &t_; -}; - -template -static inline Moveable -Move(T &t) -{ - return Moveable(t); -} - -} // namespace ke - -#endif // _include_amtl_moveable_h_ diff --git a/public/amtl/am-refcounting-threadsafe.h b/public/amtl/am-refcounting-threadsafe.h deleted file mode 100644 index 785ba62b..00000000 --- a/public/amtl/am-refcounting-threadsafe.h +++ /dev/null @@ -1,71 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_ts_refcounting_h_ -#define _include_amtl_ts_refcounting_h_ - -#include -#include - -namespace ke { - -// See the comment above Refcounted for more information. This class is -// identical, except changing the reference count is guaranteed to be atomic -// with respect to other threads changing the reference count. -template -class RefcountedThreadsafe -{ - public: - RefcountedThreadsafe() - : refcount_(0) - { - } - - void AddRef() { - refcount_.increment(); - } - bool Release() { - if (!refcount_.decrement()) { - delete static_cast(this); - return false; - } - return true; - } - - protected: - ~RefcountedThreadsafe() { - } - - private: - AtomicRefCount refcount_; -}; - -} // namespace ke - -#endif // _include_amtl_ts_refcounting_h_ diff --git a/public/amtl/am-refcounting.h b/public/amtl/am-refcounting.h deleted file mode 100644 index ea869464..00000000 --- a/public/amtl/am-refcounting.h +++ /dev/null @@ -1,336 +0,0 @@ -// vim: set sts=8 ts=4 sw=4 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_refcounting_h_ -#define _include_amtl_refcounting_h_ - -#include -#include - -namespace ke { - -template class Ref; - -// Objects in AMTL inheriting from Refcounted will have an initial refcount -// of 0. However, in some systems (such as COM), the initial refcount is 1, -// or functions may return raw pointers that have been AddRef'd. In these -// cases it would be a mistake to use Ref<> or PassRef<>, since the object -// would leak an extra reference. -// -// This container holds a refcounted object without addrefing it. This is -// intended only for interacting with functions which return an object that -// has been manually AddRef'd. Note that this will perform a Release(), so -// so it is necessary to assign it to retain the object. -template -class AlreadyRefed -{ - public: - AlreadyRefed(T *t) - : thing_(t) - { - } - AlreadyRefed(const AlreadyRefed &other) - : thing_(other.thing_) - { - // If copy elision for some reason doesn't happen (for example, when - // returning from AdoptRef), just null out the source ref. - other.thing_ = NULL; - } - ~AlreadyRefed() { - if (thing_) - thing_->Release(); - } - - T *release() const { - return ReturnAndVoid(thing_); - } - - private: - mutable T *thing_; -}; - -template -static inline AlreadyRefed -AdoptRef(T *t) -{ - return AlreadyRefed(t); -} - -// When returning a value, we'd rather not be needlessly changing the refcount, -// so we have a special type to use for returns. -template -class PassRef -{ - public: - PassRef(T *thing) - : thing_(thing) - { - AddRef(); - } - PassRef() - : thing_(NULL) - { - } - - PassRef(const AlreadyRefed &other) - : thing_(other.release()) - { - // Don't addref, newborn means already addref'd. - } - - template - PassRef(const AlreadyRefed &other) - : thing_(other.release()) - { - // Don't addref, newborn means already addref'd. - } - - template - inline PassRef(const Ref &other); - - PassRef(const PassRef &other) - : thing_(other.release()) - { - } - template - PassRef(const PassRef &other) - : thing_(other.release()) - { - } - ~PassRef() - { - Release(); - } - - operator T &() { - return *thing_; - } - operator T *() const { - return thing_; - } - T *operator ->() const { - return operator *(); - } - T *operator *() const { - return thing_; - } - bool operator !() const { - return !thing_; - } - - T *release() const { - return ReturnAndVoid(thing_); - } - - template - PassRef &operator =(const PassRef &other) { - Release(); - thing_ = other.release(); - return *this; - } - - private: - // Disallowed operators. - PassRef &operator =(T *other); - PassRef &operator =(AlreadyRefed &other); - - void AddRef() { - if (thing_) - thing_->AddRef(); - } - void Release() { - if (thing_) - thing_->Release(); - } - - private: - mutable T *thing_; -}; - -// Classes which are refcounted should inherit from this. Note that reference -// counts start at 0 in AMTL, rather than 1. This avoids the complexity of -// having to adopt the initial ref upon allocation. However, this also means -// invoking Release() on a newly allocated object is illegal. Newborn objects -// must either be assigned to a Ref or PassRef (NOT an AdoptRef/AlreadyRefed), -// or must be deleted using |delete|. -template -class Refcounted -{ - public: - Refcounted() - : refcount_(0) - { - } - - void AddRef() { - refcount_++; - } - void Release() { - assert(refcount_ > 0); - if (--refcount_ == 0) - delete static_cast(this); - } - - protected: - ~Refcounted() { - } - - private: - uintptr_t refcount_; -}; - -// Simple class for automatic refcounting. -template -class Ref -{ - public: - Ref(T *thing) - : thing_(thing) - { - AddRef(); - } - - Ref() - : thing_(NULL) - { - } - - Ref(const Ref &other) - : thing_(other.thing_) - { - AddRef(); - } - Ref(Moveable other) - : thing_(other->thing_) - { - other->thing_ = NULL; - } - template - Ref(const Ref &other) - : thing_(*other) - { - AddRef(); - } - Ref(const PassRef &other) - : thing_(other.release()) - { - } - template - Ref(const PassRef &other) - : thing_(other.release()) - { - } - Ref(const AlreadyRefed &other) - : thing_(other.release()) - { - } - template - Ref(const AlreadyRefed &other) - : thing_(other.release()) - { - } - ~Ref() - { - Release(); - } - - T *operator ->() const { - return operator *(); - } - T *operator *() const { - return thing_; - } - operator T *() { - return thing_; - } - bool operator !() const { - return !thing_; - } - - template - Ref &operator =(S *thing) { - Release(); - thing_ = thing; - AddRef(); - return *this; - } - - template - Ref &operator =(const PassRef &other) { - Release(); - thing_ = other.release(); - return *this; - } - - template - Ref &operator =(const AlreadyRefed &other) { - Release(); - thing_ = other.release(); - return *this; - } - - Ref &operator =(const Ref &other) { - Release(); - thing_ = other.thing_; - AddRef(); - return *this; - } - - Ref &operator =(Moveable other) { - Release(); - thing_ = other->thing_; - other->thing_ = NULL; - return *this; - } - - private: - void AddRef() { - if (thing_) - thing_->AddRef(); - } - void Release() { - if (thing_) - thing_->Release(); - } - - protected: - T *thing_; -}; - -template template -PassRef::PassRef(const Ref &other) - : thing_(*other) -{ - AddRef(); -} - -} // namespace ke - -#endif // _include_amtl_refcounting_h_ - diff --git a/public/amtl/am-string.h b/public/amtl/am-string.h deleted file mode 100644 index 4e62bde2..00000000 --- a/public/amtl/am-string.h +++ /dev/null @@ -1,136 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_string_h_ -#define _include_amtl_string_h_ - -#include -#include -#include -#include - -namespace ke { - -// ASCII string. -class AString -{ - public: - AString() - : length_(0) - { - } - - explicit AString(const char *str) { - set(str, strlen(str)); - } - AString(const char *str, size_t length) { - set(str, length); - } - AString(const AString &other) { - if (other.length_) - set(other.chars_, other.length_); - else - length_ = 0; - } - AString(Moveable other) - : chars_(other->chars_.take()), - length_(other->length_) - { - other->length_ = 0; - } - - AString &operator =(const char *str) { - if (str && str[0]) { - set(str, strlen(str)); - } else { - chars_ = NULL; - length_ = 0; - } - return *this; - } - AString &operator =(const AString &other) { - if (other.length_) { - set(other.chars_, other.length_); - } else { - chars_ = NULL; - length_ = 0; - } - return *this; - } - AString &operator =(Moveable other) { - chars_ = other->chars_.take(); - length_ = other->length_; - other->length_ = 0; - return *this; - } - - int compare(const char *str) const { - return strcmp(chars(), str); - } - int compare(const AString &other) const { - return strcmp(chars(), other.chars()); - } - bool operator ==(const AString &other) const { - return other.length() == length() && - memcmp(other.chars(), chars(), length()) == 0; - } - - char operator [](size_t index) const { - assert(index < length()); - return chars()[index]; - } - - size_t length() const { - return length_; - } - - const char *chars() const { - if (!chars_) - return ""; - return chars_; - } - - private: - static const size_t kInvalidLength = (size_t)-1; - - void set(const char *str, size_t length) { - chars_ = new char[length + 1]; - length_ = length; - memcpy(chars_, str, length); - chars_[length] = '\0'; - } - - private: - AutoArray chars_; - size_t length_; -}; - -} - -#endif // _include_amtl_string_h_ diff --git a/public/amtl/am-thread-posix.h b/public/amtl/am-thread-posix.h deleted file mode 100644 index c5d1b25c..00000000 --- a/public/amtl/am-thread-posix.h +++ /dev/null @@ -1,219 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_thread_posix_h_ -#define _include_amtl_thread_posix_h_ - -#include -#include -#include -#include -#if defined(__linux__) -# include -#endif -#if defined(__APPLE__) -# include -#endif - -namespace ke { - -class Mutex : public Lockable -{ - public: - Mutex() { -#if !defined(NDEBUG) - int rv = -#endif - pthread_mutex_init(&mutex_, NULL); - assert(rv == 0); - } - ~Mutex() { - pthread_mutex_destroy(&mutex_); - } - - bool DoTryLock() KE_OVERRIDE { - return pthread_mutex_trylock(&mutex_) == 0; - } - - void DoLock() KE_OVERRIDE { - pthread_mutex_lock(&mutex_); - } - - void DoUnlock() KE_OVERRIDE { - pthread_mutex_unlock(&mutex_); - } - - pthread_mutex_t *raw() { - return &mutex_; - } - - private: - pthread_mutex_t mutex_; -}; - -// Currently, this class only supports single-listener CVs. -class ConditionVariable : public Lockable -{ - public: - ConditionVariable() { -#if !defined(NDEBUG) - int rv = -#endif - pthread_cond_init(&cv_, NULL); - assert(rv == 0); - } - ~ConditionVariable() { - pthread_cond_destroy(&cv_); - } - - bool DoTryLock() KE_OVERRIDE { - return mutex_.DoTryLock(); - } - void DoLock() KE_OVERRIDE { - mutex_.DoLock(); - } - void DoUnlock() KE_OVERRIDE { - mutex_.DoUnlock(); - } - - void Notify() { - AssertCurrentThreadOwns(); - pthread_cond_signal(&cv_); - } - - WaitResult Wait(size_t timeout_ms) { - AssertCurrentThreadOwns(); - -#if defined(__linux__) - struct timespec ts; - if (clock_gettime(CLOCK_REALTIME, &ts) == -1) - return Wait_Error; -#else - struct timeval tv; - gettimeofday(&tv, NULL); - - struct timespec ts; - ts.tv_sec = tv.tv_sec; - ts.tv_nsec = tv.tv_usec * 1000; -#endif - - ts.tv_sec += timeout_ms / 1000; - ts.tv_nsec += (timeout_ms % 1000) * 1000000; - if (ts.tv_nsec >= 1000000000) { - ts.tv_sec++; - ts.tv_nsec -= 1000000000; - } - - DebugSetUnlocked(); - int rv = pthread_cond_timedwait(&cv_, mutex_.raw(), &ts); - DebugSetLocked(); - - if (rv == ETIMEDOUT) - return Wait_Timeout; - if (rv == 0) - return Wait_Signaled; - return Wait_Error; - } - - WaitResult Wait() { - AssertCurrentThreadOwns(); - - DebugSetUnlocked(); - int rv = pthread_cond_wait(&cv_, mutex_.raw()); - DebugSetLocked(); - - if (rv == 0) - return Wait_Signaled; - return Wait_Error; - } - - private: - Mutex mutex_; - pthread_cond_t cv_; -}; - -class Thread -{ - struct ThreadData { - IRunnable *run; - char name[17]; - }; - public: - Thread(IRunnable *run, const char *name = NULL) { - ThreadData *data = new ThreadData; - data->run = run; - snprintf(data->name, sizeof(data->name), "%s", name ? name : ""); - - initialized_ = (pthread_create(&thread_, NULL, Main, data) == 0); - if (!initialized_) - delete data; - } - ~Thread() { - if (!Succeeded()) - return; - pthread_detach(thread_); - } - - bool Succeeded() const { - return initialized_; - } - - void Join() { - if (!Succeeded()) - return; - pthread_join(thread_, NULL); - initialized_ = false; - } - - private: - static void *Main(void *arg) { - AutoPtr data((ThreadData *)arg); - - if (data->name[0]) { -#if defined(__linux__) - prctl(PR_SET_NAME, (unsigned long)data->name); -#elif defined(__APPLE__) - int (*fn)(const char *) = (int (*)(const char *))dlsym(RTLD_DEFAULT, "pthread_setname_np"); - if (fn) - fn(data->name); -#endif - } - data->run->Run(); - return NULL; - } - - private: - bool initialized_; - pthread_t thread_; -}; - -} // namespace ke - -#endif // _include_amtl_thread_posix_h_ - diff --git a/public/amtl/am-thread-utils.h b/public/amtl/am-thread-utils.h deleted file mode 100644 index 98db2616..00000000 --- a/public/amtl/am-thread-utils.h +++ /dev/null @@ -1,265 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_threads_ -#define _include_amtl_threads_ - -#include -#if defined(_MSC_VER) -# include -# include -#else -# include -#endif -#include - -// Thread primitives for SourcePawn. -// -// Linking Requirements: -// -// OS X: None (-lpthread and -ldl are optional) -// Windows: None -// Linux: -lpthread -lrt required -// -// -- Mutexes -- -// -// A Lockable is a mutual exclusion primitive. It can be owned by at most one -// thread at a time, and ownership blocks any other thread from taking taking -// ownership. Ownership must be acquired and released on the same thread. -// Lockables are not re-entrant. -// -// While a few classes support the Lockable interface, the simplest Lockable -// object that can be instantiated is a Mutex. -// -// -- Condition Variables -- -// -// A ConditionVariable provides mutually exclusive access based on a -// condition ocurring. CVs provide two capabilities: Wait(), which will block -// until the condition is triggered, and Notify(), which signals any blocking -// thread that the condition has occurred. -// -// Condition variables have an underlying mutex lock. This lock must be -// acquired before calling Wait() or Notify(). It is automatically released -// once Wait begins blocking. This operation is atomic with respect to other -// threads and the mutex. For example, it is not possible for the lock to be -// acquired by another thread in between unlocking and blocking. Since Notify -// also requires the lock to be acquired, there is no risk of an event -// accidentally dissipating into thin air because it was sent before the other -// thread began blocking. -// -// When Wait() returns, the lock is automatically re-acquired. This operation -// is NOT atomic. In between waking up and re-acquiring the lock, another -// thread may steal the lock and issue another event. Applications must -// account for this. For example, a message pump should check that there are -// no messages left to process before blocking again. -// -// Likewise, it is also not defined whether a Signal() will have any effect -// while a thread is not waiting on the monitor. This is yet another reason -// the above paragraph is so important - applications should, under a lock of -// the condition variable - check for state changes before waiting. -// -// -- Threads -- -// -// A Thread object, when created, spawns a new thread with the given callback -// (the callbacks must implement IRunnable). Threads have one method of -// interest, Join(), which will block until the thread's execution finishes. -// Deleting a thread object will free any operating system resources associated -// with that thread, if the thread has finished executing. -// -// Threads can fail to spawn; make sure to check Succeeded(). -// - -namespace ke { - -// Abstraction for getting a unique thread identifier. Debug-only. -#if defined(_MSC_VER) -typedef DWORD ThreadId; - -static inline ThreadId GetCurrentThreadId() -{ - return ::GetCurrentThreadId(); -} -#else -typedef pthread_t ThreadId; - -static inline ThreadId GetCurrentThreadId() -{ - return pthread_self(); -} -#endif - -// Classes which use non-reentrant, same-thread lock/unlock semantics should -// inherit from this and implement DoLock/DoUnlock. -class Lockable -{ - public: - Lockable() - { -#if !defined(NDEBUG) - owner_ = 0; -#endif - } - virtual ~Lockable() { - } - - bool TryLock() { - if (DoTryLock()) { - DebugSetLocked(); - return true; - } - return false; - } - - void Lock() { - assert(Owner() != GetCurrentThreadId()); - DoLock(); - DebugSetLocked(); - } - - void Unlock() { - assert(Owner() == GetCurrentThreadId()); - DebugSetUnlocked(); - DoUnlock(); - } - - void AssertCurrentThreadOwns() const { - assert(Owner() == GetCurrentThreadId()); - } -#if !defined(NDEBUG) - bool Locked() const { - return owner_ != 0; - } - ThreadId Owner() const { - return owner_; - } -#endif - - virtual bool DoTryLock() = 0; - virtual void DoLock() = 0; - virtual void DoUnlock() = 0; - - protected: - void DebugSetUnlocked() { -#if !defined(NDEBUG) - owner_ = 0; -#endif - } - void DebugSetLocked() { -#if !defined(NDEBUG) - owner_ = GetCurrentThreadId(); -#endif - } - - protected: -#if !defined(NDEBUG) - ThreadId owner_; -#endif -}; - -// RAII for automatically locking and unlocking an object. -class AutoLock -{ - public: - AutoLock(Lockable *lock) - : lock_(lock) - { - lock_->Lock(); - } - ~AutoLock() { - lock_->Unlock(); - } - - private: - Lockable *lock_; -}; - -class AutoTryLock -{ - public: - AutoTryLock(Lockable *lock) - { - lock_ = lock->TryLock() ? lock : NULL; - } - ~AutoTryLock() { - if (lock_) - lock_->Unlock(); - } - - private: - Lockable *lock_; -}; - -// RAII for automatically unlocking and relocking an object. -class AutoUnlock -{ - public: - AutoUnlock(Lockable *lock) - : lock_(lock) - { - lock_->Unlock(); - } - ~AutoUnlock() { - lock_->Lock(); - } - - private: - Lockable *lock_; -}; - -enum WaitResult { - // Woke up because something happened. - Wait_Signaled, - - // Woke up because nothing happened and a timeout was specified. - Wait_Timeout, - - // Woke up, but because of an error. - Wait_Error -}; - -// This must be implemented in order to spawn a new thread. -class IRunnable -{ - public: - virtual ~IRunnable() { - } - - virtual void Run() = 0; -}; - -} // namespace ke - -// Include the actual thread implementations. -#if defined(_MSC_VER) -# include "am-thread-windows.h" -#else -# include "am-thread-posix.h" -#endif - -#endif // _include_amtl_threads_ diff --git a/public/amtl/am-thread-windows.h b/public/amtl/am-thread-windows.h deleted file mode 100644 index c4e34ed2..00000000 --- a/public/amtl/am-thread-windows.h +++ /dev/null @@ -1,161 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_thread_windows_h_ -#define _include_amtl_thread_windows_h_ - -#include - -namespace ke { - -class CriticalSection : public Lockable -{ - public: - CriticalSection() { - InitializeCriticalSection(&cs_); - } - ~CriticalSection() { - DeleteCriticalSection(&cs_); - } - - bool DoTryLock() KE_OVERRIDE { - return !!TryEnterCriticalSection(&cs_); - } - void DoLock() KE_OVERRIDE { - EnterCriticalSection(&cs_); - } - - void DoUnlock() KE_OVERRIDE { - LeaveCriticalSection(&cs_); - } - - private: - CRITICAL_SECTION cs_; -}; - -typedef CriticalSection Mutex; - -// Currently, this class only supports single-listener CVs. -class ConditionVariable : public Lockable -{ - public: - ConditionVariable() { - event_ = CreateEvent(NULL, FALSE, FALSE, NULL); - } - ~ConditionVariable() { - CloseHandle(event_); - } - - bool DoTryLock() KE_OVERRIDE { - return cs_.DoTryLock(); - } - void DoLock() KE_OVERRIDE { - cs_.DoLock(); - } - void DoUnlock() KE_OVERRIDE { - cs_.DoUnlock(); - } - - void Notify() { - AssertCurrentThreadOwns(); - SetEvent(event_); - } - - WaitResult Wait(size_t timeout_ms) { - // This will assert if the lock has not been acquired. We don't need to be - // atomic here, like pthread_cond_wait, because the event bit will stick - // until reset by a wait function. - Unlock(); - DWORD rv = WaitForSingleObject(event_, timeout_ms); - Lock(); - - if (rv == WAIT_TIMEOUT) - return Wait_Timeout; - if (rv == WAIT_FAILED) - return Wait_Error; - return Wait_Signaled; - } - - WaitResult Wait() { - return Wait(INFINITE); - } - - private: - CriticalSection cs_; - HANDLE event_; -}; - -class Thread -{ - public: - Thread(IRunnable *run, const char *name = NULL) { - thread_ = CreateThread(NULL, 0, Main, run, 0, NULL); - } - ~Thread() { - if (!thread_) - return; - CloseHandle(thread_); - } - - bool Succeeded() const { - return !!thread_; - } - - void Join() { - if (!Succeeded()) - return; - WaitForSingleObject(thread_, INFINITE); - } - - HANDLE handle() const { - return thread_; - } - - private: - static DWORD WINAPI Main(LPVOID arg) { - ((IRunnable *)arg)->Run(); - return 0; - } - -#pragma pack(push, 8) - struct ThreadNameInfo { - DWORD dwType; - LPCSTR szName; - DWORD dwThreadID; - DWORD dwFlags; - }; -#pragma pack(pop) - - private: - HANDLE thread_; -}; - -} // namespace ke - -#endif // _include_amtl_thread_windows_h_ diff --git a/public/amtl/am-threadlocal.h b/public/amtl/am-threadlocal.h deleted file mode 100644 index df4c023c..00000000 --- a/public/amtl/am-threadlocal.h +++ /dev/null @@ -1,175 +0,0 @@ -// vim: set sts=2 ts=8 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_thread_local_h_ -#define _include_amtl_thread_local_h_ - -#include - -namespace ke { - -// Stores a per-thread value. In single-threaded mode (KE_SINGLE_THREADED), -// this is a no-op container wrapper. -// -// T must be castable to uintptr_t. -// -// When assigning to a ThreadLocal, the assigment will automatically attempt -// to allocate thread-local storage from the operating system. If it fails, it -// will abort the program. If this is undesirable, you may call allocate() -// up-front and handle the error case manually. -// -// The number of thread local slots available to processes is limited (on -// Linux, it is generally 1024). It is best to use ThreadLocal sparingly to -// play nicely with other libraries. -// -// ThreadLocal will free the underlying thread-local storage slot in its -// destructor, but it is not an AutoPtr. It does not delete pointers. Since -// one thread's value is only observable from that thread, make sure to free -// the contained resource (if necessary) before the thread exits. -template -class ThreadLocal -{ - public: - void operator =(const T &other) { - set(other); - } - - T operator *() const { - return get(); - } - T operator ->() const { - return get(); - } - bool operator !() const { - return !get(); - } - bool operator ==(const T &other) const { - return get() == other; - } - bool operator !=(const T &other) const { - return get() != other; - } - - private: - ThreadLocal(const ThreadLocal &other) KE_DELETE; - ThreadLocal &operator =(const ThreadLocal &other) KE_DELETE; - -#if !defined(KE_SINGLE_THREADED) - private: - int allocated_; - - public: - ThreadLocal() { - allocated_ = 0; - } - - T get() const { - if (!allocated_) - return T(); - return internalGet(); - } - void set(const T &t) { - if (!allocated_ && !allocate()) { - fprintf(stderr, "could not allocate thread-local storage\n"); - abort(); - } - internalSet(t); - } - -# if defined(_MSC_VER) - ~ThreadLocal() { - if (allocated_) - TlsFree(key_); - } - - private: - T internalGet() const { - return reinterpret_cast(TlsGetValue(key_)); - } - void internalSet(const T &t) { - TlsSetValue(key_, reinterpret_cast(t)); - } - bool allocate() { - if (InterlockedCompareExchange(&allocated_, 1, 0) == 1) - return true; - key_ = TlsAlloc(); - return key_ != TLS_OUT_OF_INDEXES; - } - - DWORD key_; - -# else - public: - ~ThreadLocal() { - if (allocated_) - pthread_key_delete(key_); - } - - bool allocate() { - if (!__sync_bool_compare_and_swap(&allocated_, 0, 1)) - return true; - return pthread_key_create(&key_, NULL) == 0; - } - - private: - T internalGet() const { - return (T)reinterpret_cast(pthread_getspecific(key_)); - } - void internalSet(const T &t) { - pthread_setspecific(key_, reinterpret_cast(t)); - } - - pthread_key_t key_; -# endif // !_MSC_VER - -#else // KE_SINGLE_THREADED - public: - ThreadLocal() { - t_ = T(); - } - - bool allocate() { - return true; - } - - T get() const { - return t_; - } - void set(const T &t) { - t_ = t; - } - - private: - T t_; -#endif -}; - -} // namespace ke - -#endif // _include_amtl_thread_local_h_ diff --git a/public/amtl/am-utility.h b/public/amtl/am-utility.h deleted file mode 100644 index 25417fab..00000000 --- a/public/amtl/am-utility.h +++ /dev/null @@ -1,405 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _include_amtl_utility_h_ -#define _include_amtl_utility_h_ - -#include -#include -#include -#include -#if defined(_MSC_VER) -# include -#endif -#include - -#define KE_32BIT - -#if defined(_MSC_VER) -# pragma warning(disable:4355) -#endif - -namespace ke { - -static const size_t kMallocAlignment = sizeof(void *) * 2; - -static const size_t kKB = 1024; -static const size_t kMB = 1024 * kKB; -static const size_t kGB = 1024 * kMB; - -typedef uint8_t * Address; - -template T -ReturnAndVoid(T &t) -{ - T saved = t; - t = T(); - return saved; -} - -#if __cplusplus >= 201103L -# define KE_CXX11 -#endif - -#if defined(KE_CXX11) -# define KE_DELETE = delete -# define KE_OVERRIDE override -#else -# define KE_DELETE -# define KE_OVERRIDE -#endif - -// Wrapper that automatically deletes its contents. The pointer can be taken -// to avoid destruction. -template -class AutoPtr -{ - T *t_; - - public: - AutoPtr() - : t_(NULL) - { - } - explicit AutoPtr(T *t) - : t_(t) - { - } - AutoPtr(Moveable > other) - { - t_ = other->t_; - other->t_ = NULL; - } - ~AutoPtr() { - delete t_; - } - T *take() { - return ReturnAndVoid(t_); - } - T *operator *() const { - return t_; - } - T *operator ->() const { - return t_; - } - operator T *() const { - return t_; - } - T *operator =(T *t) { - delete t_; - t_ = t; - return t_; - } - T *operator =(Moveable > other) { - delete t_; - t_ = other->t_; - other->t_ = NULL; - return t_; - } - bool operator !() const { - return !t_; - } - - private: - AutoPtr(const AutoPtr &other) KE_DELETE; - AutoPtr &operator =(const AutoPtr &other) KE_DELETE; -}; - -// Wrapper that automatically deletes its contents. The pointer can be taken -// to avoid destruction. -template -class AutoArray -{ - T *t_; - - public: - AutoArray() - : t_(NULL) - { - } - explicit AutoArray(T *t) - : t_(t) - { - } - ~AutoArray() { - delete [] t_; - } - T *take() { - return ReturnAndVoid(t_); - } - T *operator *() const { - return t_; - } - T &operator [](size_t index) { - return t_[index]; - } - const T &operator [](size_t index) const { - return t_[index]; - } - operator T *() const { - return t_; - } - void operator =(T *t) { - delete [] t_; - t_ = t; - } - bool operator !() const { - return !t_; - } -}; - -static inline size_t -Log2(size_t number) -{ - assert(number != 0); - -#if defined _MSC_VER - unsigned long rval; -# ifdef _M_IX86 - _BitScanReverse(&rval, number); -# elif _M_X64 - _BitScanReverse64(&rval, number); -# endif - return rval; -#elif defined __GNUC__ - return 31 - __builtin_clz(number); -#else - size_t bit; - asm("bsr %1, %0\n" - : "=r" (bit) - : "rm" (number)); - return bit; -#endif -} - -static inline size_t -FindRightmostBit(size_t number) -{ - assert(number != 0); - -#if defined _MSC_VER - unsigned long rval; -# ifdef _M_IX86 - _BitScanForward(&rval, number); -# elif _M_X64 - _BitScanForward64(&rval, number); -# endif - return rval; -#elif defined __GNUC__ - return __builtin_ctz(number); -#else - size_t bit; - asm("bsf %1, %0\n" - : "=r" (bit) - : "rm" (number)); - return bit; -#endif -} - -static inline bool -IsPowerOfTwo(size_t value) -{ - if (value == 0) - return false; - return !(value & (value - 1)); -} - -static inline size_t -Align(size_t count, size_t alignment) -{ - assert(IsPowerOfTwo(alignment)); - return count + (alignment - (count % alignment)) % alignment; -} - -static inline bool -IsUint32AddSafe(unsigned a, unsigned b) -{ - if (!a || !b) - return true; - size_t log2_a = Log2(a); - size_t log2_b = Log2(b); - return (log2_a < sizeof(unsigned) * 8) && - (log2_b < sizeof(unsigned) * 8); -} - -static inline bool -IsUintPtrAddSafe(size_t a, size_t b) -{ - if (!a || !b) - return true; - size_t log2_a = Log2(a); - size_t log2_b = Log2(b); - return (log2_a < sizeof(size_t) * 8) && - (log2_b < sizeof(size_t) * 8); -} - -static inline bool -IsUint32MultiplySafe(unsigned a, unsigned b) -{ - if (a <= 1 || b <= 1) - return true; - - size_t log2_a = Log2(a); - size_t log2_b = Log2(b); - return log2_a + log2_b <= sizeof(unsigned) * 8; -} - -static inline bool -IsUintPtrMultiplySafe(size_t a, size_t b) -{ - if (a <= 1 || b <= 1) - return true; - - size_t log2_a = Log2(a); - size_t log2_b = Log2(b); - return log2_a + log2_b <= sizeof(size_t) * 8; -} - -#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0])) -#define STATIC_ASSERT(cond) extern int static_assert_f(int a[(cond) ? 1 : -1]) - -#define IS_ALIGNED(addr, alignment) (!(uintptr_t(addr) & ((alignment) - 1))) - -template -static inline bool -IsAligned(T addr, size_t alignment) -{ - assert(IsPowerOfTwo(alignment)); - return !(uintptr_t(addr) & (alignment - 1)); -} - -static inline Address -AlignedBase(Address addr, size_t alignment) -{ - assert(IsPowerOfTwo(alignment)); - return Address(uintptr_t(addr) & ~(alignment - 1)); -} - -template static inline T -Min(const T &t1, const T &t2) -{ - return t1 < t2 ? t1 : t2; -} - -template static inline T -Max(const T &t1, const T &t2) -{ - return t1 > t2 ? t1 : t2; -} - -template -class StorageBuffer -{ - public: - T *address() { - return reinterpret_cast(buffer_); - } - const T *address() const { - return reinterpret_cast(buffer_); - } - - private: - union { - char buffer_[sizeof(T)]; - uint64_t aligned_; - }; -}; - -template -class SaveAndSet -{ - public: - SaveAndSet(T *location, const T &value) - : location_(location), - old_(*location) - { - *location_ = value; - } - ~SaveAndSet() { - *location_ = old_; - } - - private: - T *location_; - T old_; -}; - -template -class StackLinked -{ - public: - StackLinked(T **prevp) - : prevp_(prevp), - prev_(*prevp) - { - *prevp_ = static_cast(this); - } - virtual ~StackLinked() { - assert(*prevp_ == this); - *prevp_ = prev_; - } - - private: - T **prevp_; - T *prev_; -}; - -#if __cplusplus >= 201103L -# define KE_CXX11 -#endif - -#if defined(KE_CXX11) -# define KE_DELETE = delete -# define KE_OVERRIDE override -#else -# define KE_DELETE -# define KE_OVERRIDE -#endif - -#if defined(_MSC_VER) -# define KE_SIZET_FMT "%Iu" -# define KE_I64_FMT "%I64d" -# define KE_U64_FMT "%I64u" -#elif defined(__GNUC__) -# define KE_SIZET_FMT "%zu" -# define KE_I64_FMT "%lld" -# define KE_U64_FMT "%llu" -#else -# error "Implement format specifier string" -#endif - -#if defined(__GNUC__) -# define KE_CRITICAL_LIKELY(x) __builtin_expect(!!(x), 1) -#else -# define KE_CRITICAL_LIKELY(x) x -#endif - -} - -#endif // _include_amtl_utility_h_ diff --git a/public/amtl/am-vector.h b/public/amtl/am-vector.h deleted file mode 100644 index 4f01bb97..00000000 --- a/public/amtl/am-vector.h +++ /dev/null @@ -1,252 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 et: -// -// Copyright (C) 2013, David Anderson and AlliedModders LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of AlliedModders LLC nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef _INCLUDE_KEIMA_TPL_CPP_VECTOR_H_ -#define _INCLUDE_KEIMA_TPL_CPP_VECTOR_H_ - -#include -#include -#include -#include -#include - -namespace ke { - -template -class Vector : public AllocPolicy -{ - public: - Vector(AllocPolicy = AllocPolicy()) - : data_(NULL), - nitems_(0), - maxsize_(0) - { - } - - Vector(Moveable > other) { - data_ = other->data_; - nitems_ = other->nitems_; - maxsize_ = other->maxsize_; - other->reset(); - } - - ~Vector() { - zap(); - } - - bool append(const T &item) { - if (!growIfNeeded(1)) - return false; - new (&data_[nitems_]) T(item); - nitems_++; - return true; - } - bool append(Moveable item) { - if (!growIfNeeded(1)) - return false; - new (&data_[nitems_]) T(item); - nitems_++; - return true; - } - void infallibleAppend(const T &item) { - assert(growIfNeeded(1)); - new (&data_[nitems_]) T(item); - nitems_++; - } - void infallibleAppend(Moveable item) { - assert(growIfNeeded(1)); - new (&data_[nitems_]) T(item); - nitems_++; - } - - // Shift all elements including |at| up by one, and insert |item| at the - // given position. If |at| is one greater than the last usable index, - // i.e. |at == length()|, then this is the same as append(). No other - // invalid indexes are allowed. - // - // This is a linear-time operation. - bool insert(size_t at, const T &item) { - if (at == length()) - return append(item); - if (!moveUp(at)) - return false; - new (&data_[at]) T(item); - return true; - } - bool insert(size_t at, Moveable item) { - if (at == length()) - return append(item); - if (!moveUp(at)) - return false; - new (&data_[at]) T(item); - return true; - } - - // Shift all elements at the given position down, removing the given - // element. This is a linear-time operation. - void remove(size_t at) { - for (size_t i = at; i < length() - 1; i++) - data_[i] = Moveable(data_[i + 1]); - pop(); - } - - T popCopy() { - T t = at(length() - 1); - pop(); - return t; - } - void pop() { - assert(nitems_); - data_[nitems_ - 1].~T(); - nitems_--; - } - bool empty() const { - return length() == 0; - } - size_t length() const { - return nitems_; - } - T& at(size_t i) { - assert(i < length()); - return data_[i]; - } - const T& at(size_t i) const { - assert(i < length()); - return data_[i]; - } - T& operator [](size_t i) { - return at(i); - } - const T& operator [](size_t i) const { - return at(i); - } - void clear() { - nitems_ = 0; - } - const T &back() const { - return at(length() - 1); - } - T &back() { - return at(length() - 1); - } - - T *buffer() const { - return data_; - } - - bool ensure(size_t desired) { - if (desired <= length()) - return true; - - return growIfNeeded(desired - length()); - } - - Vector &operator =(Moveable > other) { - data_ = other->data_; - nitems_ = other->nitems_; - maxsize_ = other->maxsize_; - other->reset(); - return *this; - } - - private: - // These are disallowed because they basically violate the failure handling - // model for AllocPolicies and are also likely to have abysmal performance. - Vector(const Vector &other) KE_DELETE; - Vector &operator =(const Vector &other) KE_DELETE; - - private: - void zap() { - for (size_t i = 0; i < nitems_; i++) - data_[i].~T(); - this->free(data_); - } - void reset() { - data_ = NULL; - nitems_ = 0; - maxsize_ = 0; - } - - bool moveUp(size_t at) { - // Note: we don't use append() here. Passing an element as a Moveable into - // insert() or append() can break, since the underlying storage could be - // reallocated, invalidating the Moveable reference. Instead, we inline - // the logic to append() to ensure growIfNeeded occurs before any - // references are taken. - if (!growIfNeeded(1)) - return false; - new (&data_[nitems_]) T(Moveable(data_[nitems_ - 1])); - nitems_++; - for (size_t i = nitems_ - 2; i > at; i--) - data_[i] = Moveable(data_[i - 1]); - return true; - } - - bool growIfNeeded(size_t needed) - { - if (!IsUintPtrAddSafe(nitems_, needed)) { - this->reportAllocationOverflow(); - return false; - } - if (nitems_ + needed < maxsize_) - return true; - - size_t new_maxsize = maxsize_ ? maxsize_ : 8; - while (nitems_ + needed > new_maxsize) { - if (!IsUintPtrMultiplySafe(new_maxsize, 2)) { - this->reportAllocationOverflow(); - return false; - } - new_maxsize *= 2; - } - - T* newdata = (T*)this->malloc(sizeof(T) * new_maxsize); - if (newdata == NULL) - return false; - for (size_t i = 0; i < nitems_; i++) { - new (&newdata[i]) T(Moveable(data_[i])); - data_[i].~T(); - } - this->free(data_); - - data_ = newdata; - maxsize_ = new_maxsize; - return true; - } - - private: - T* data_; - size_t nitems_; - size_t maxsize_; -}; - -} - -#endif /* _INCLUDE_KEIMA_TPL_CPP_VECTOR_H_ */ - diff --git a/public/asm/asm.c b/public/asm/asm.c index 2facf8d9..da447479 100644 --- a/public/asm/asm.c +++ b/public/asm/asm.c @@ -4,6 +4,8 @@ #define _GNU_SOURCE #include #include +#include +#include #define REG_EAX 0 #define REG_ECX 1 @@ -13,8 +15,6 @@ #define IA32_MOV_REG_IMM 0xB8 // encoding is +r #endif -extern void Msg( const char *, ... ); - /** * Checks if a call to a fpic thunk has just been written into dest. * If found replaces it with a direct mov that sets the required register to the value of pc. @@ -25,9 +25,7 @@ extern void Msg( const char *, ... ); */ void check_thunks(unsigned char *dest, unsigned char *pc) { -#if defined WIN32 - return; -#else +#ifndef WIN32 /* Step write address back 4 to the start of the function address */ unsigned char *writeaddr = dest - 4; unsigned char *calloffset = *(unsigned char **)writeaddr; @@ -64,7 +62,10 @@ void check_thunks(unsigned char *dest, unsigned char *pc) } default: { - Msg("Unknown thunk: %c\n", *(calladdr+1)); + printf("Unknown thunk: %c\n", *(calladdr+1)); +#ifndef NDEBUG + abort(); +#endif break; } } @@ -81,8 +82,6 @@ void check_thunks(unsigned char *dest, unsigned char *pc) *(void **)writeaddr = (void *)pc; writeaddr += 4; } - - return; #endif } diff --git a/public/jit/assembler.h b/public/jit/assembler.h deleted file mode 100644 index c156cd00..00000000 --- a/public/jit/assembler.h +++ /dev/null @@ -1,294 +0,0 @@ -/** - * vim: set ts=8 sts=2 sw=2 tw=99 et: - * ============================================================================= - * SourcePawn JIT SDK - * Copyright (C) 2004-2013 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 . - * - * 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 . - * - * Version: $Id$ - */ -#ifndef _include_sourcepawn_assembler_h__ -#define _include_sourcepawn_assembler_h__ - -#include -#include -#include -#include -#include - -class Assembler -{ - public: - static const size_t kMinBufferSize = 4096; - static const size_t kMaxInstructionSize = 32; - static const size_t kMaxBufferSize = INT_MAX / 2; - - public: - Assembler() { - buffer_ = (uint8_t *)malloc(kMinBufferSize); - pos_ = buffer_; - end_ = buffer_ + kMinBufferSize; - outOfMemory_ = !buffer_; - } - ~Assembler() { - free(buffer_); - } - - bool outOfMemory() const { - return outOfMemory_; - } - - // Amount needed to allocate for executable code. - size_t length() const { - return pos_ - buffer_; - } - - // Current offset into the code stream. - uint32_t pc() const { - return uint32_t(pos_ - buffer_); - } - - protected: - void writeByte(uint8_t byte) { - write(byte); - } - void writeInt32(int32_t word) { - write(word); - } - void writeUint32(uint32_t word) { - write(word); - } - void writePointer(void *ptr) { - write(ptr); - } - - template - void write(const T &t) { - assertCanWrite(sizeof(T)); - *reinterpret_cast(pos_) = t; - pos_ += sizeof(T); - } - - // Normally this does not need to be checked, but it must be called before - // emitting any instruction. - bool ensureSpace() { - if (pos_ + kMaxInstructionSize <= end_) - return true; - - if (outOfMemory()) - return false; - - size_t oldlength = size_t(end_ - buffer_); - - if (oldlength * 2 > kMaxBufferSize) { - // See comment when if realloc() fails. - pos_ = buffer_; - outOfMemory_ = true; - return false; - } - - size_t oldpos = size_t(pos_ - buffer_); - uint8_t *newbuf = (uint8_t *)realloc(buffer_, oldlength * 2); - if (!newbuf) { - // Writes will be safe, though we'll corrupt the instruction stream, so - // actually using the buffer will be invalid and compilation should be - // aborted when possible. - pos_ = buffer_; - outOfMemory_ = true; - return false; - } - buffer_ = newbuf; - end_ = newbuf + oldlength * 2; - pos_ = buffer_ + oldpos; - return true; - } - - // Position will never be negative, but it's nice to have signed results - // for relative address calculation. - int32_t position() const { - return int32_t(pos_ - buffer_); - } - - protected: - void assertCanWrite(size_t bytes) { - assert(pos_ + bytes <= end_); - } - uint8_t *buffer() const { - return buffer_; - } - - private: - uint8_t *buffer_; - uint8_t *end_; - - protected: - uint8_t *pos_; - bool outOfMemory_; -}; - -class ExternalAddress -{ - public: - explicit ExternalAddress(void *p) - : p_(p) - { - } - - void *address() const { - return p_; - } - uintptr_t value() const { - return uintptr_t(p_); - } - - private: - void *p_; -}; - -// A label is a lightweight object to assist in managing relative jumps. It -// exists in three states: -// * Unbound, Unused: The label has no incoming jumps, and its position has -// not yet been fixed in the instruction stream. -// * Unbound, Used: The label has not yet been fixed at a position in the -// instruction stream, but it has incoming jumps. -// * Bound: The label has been fixed at a position in the instruction stream. -// -// When a label is unbound and used, the offset stored in the Label is a linked -// list threaded through each individual jump. When the label is bound, each -// jump instruction in this list is immediately patched with the correctly -// computed relative distance to the label. -// -// We keep sizeof(Label) == 4 to make it embeddable within code streams if -// need be (for example, SourcePawn mirrors the source code to maintain jump -// maps). -class Label -{ - // If set on status_, the label is bound. - static const int32_t kBound = (1 << 0); - - public: - Label() - : status_(0) - { - } - ~Label() - { - assert(!used() || bound()); - } - - static inline bool More(uint32_t status) { - return status != 0; - } - static inline uint32_t ToOffset(uint32_t status) { - return status >> 1; - } - - bool used() const { - return bound() || !!(status_ >> 1); - } - bool bound() const { - return !!(status_ & kBound); - } - uint32_t offset() const { - assert(bound()); - return ToOffset(status_); - } - uint32_t status() const { - assert(!bound()); - return status_; - } - uint32_t addPending(uint32_t pc) { - assert(pc <= INT_MAX / 2); - uint32_t prev = status_; - status_ = pc << 1; - return prev; - } - void bind(uint32_t offset) { - assert(!bound()); - status_ = (offset << 1) | kBound; - assert(this->offset() == offset); - } - - private: - // Note that 0 as an invalid offset is okay, because the offset we save for - // pending jumps are after the jump opcode itself, and therefore 0 is never - // valid, since there are no 0-byte jumps. - uint32_t status_; -}; - -// A DataLabel is a special form of Label intended for absolute addresses that -// are within the code buffer, and thus aren't known yet, and will be -// automatically fixed up when calling emitToExecutableMemory(). -// -// Unlike normal Labels, these do not store a list of incoming uses. -class DataLabel -{ - // If set on status_, the label is bound. - static const int32_t kBound = (1 << 0); - - public: - DataLabel() - : status_(0) - { - } - ~DataLabel() - { - assert(!used() || bound()); - } - - static inline uint32_t ToOffset(uint32_t status) { - return status >> 1; - } - - bool used() const { - return bound() || !!(status_ >> 1); - } - bool bound() const { - return !!(status_ & kBound); - } - uint32_t offset() const { - assert(bound()); - return ToOffset(status_); - } - uint32_t status() const { - assert(!bound()); - return status_; - } - void use(uint32_t pc) { - assert(!used()); - status_ = (pc << 1); - assert(ToOffset(status_) == pc); - } - void bind(uint32_t offset) { - assert(!bound()); - status_ = (offset << 1) | kBound; - assert(this->offset() == offset); - } - - private: - uint32_t status_; -}; - -#endif // _include_sourcepawn_assembler_h__ - diff --git a/public/jit/x86/assembler-x86.cpp b/public/jit/x86/assembler-x86.cpp deleted file mode 100644 index f00585aa..00000000 --- a/public/jit/x86/assembler-x86.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/** - * vim: set ts=8 sts=2 sw=2 tw=99 et: - * ============================================================================= - * SourcePawn JIT SDK - * 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 . - * - * 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 . - * - * Version: $Id$ - */ -#include - -CPUFeatures AssemblerX86::X86Features; diff --git a/public/jit/x86/assembler-x86.h b/public/jit/x86/assembler-x86.h deleted file mode 100644 index b766bb54..00000000 --- a/public/jit/x86/assembler-x86.h +++ /dev/null @@ -1,977 +0,0 @@ -/** - * vim: set ts=8 sts=2 sw=2 tw=99 et: - * ============================================================================= - * SourcePawn JIT SDK - * 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 . - * - * 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 . - * - * Version: $Id$ - */ -#ifndef _include_sourcepawn_assembler_x86_h__ -#define _include_sourcepawn_assembler_x86_h__ - -#include -#include -#include - -struct Register -{ - const char *name() const { - static const char *names[] = { - "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" - }; - return names[code]; - } - - int code; - - bool operator == (const Register &other) const { - return code == other.code; - } - bool operator != (const Register &other) const { - return code != other.code; - } -}; - -// X86 has an ancient FPU (called x87) which has a stack of registers -// numbered st0 through st7. -struct FpuRegister -{ - const char *name() const { - static const char *names[] = { - "st0", "st1", "st2", "st3", "st4", "st5", "st6", "st7" - }; - return names[code]; - } - - int code; - - bool operator == (const FpuRegister &other) const { - return code == other.code; - } - bool operator != (const FpuRegister &other) const { - return code != other.code; - } -}; - -struct FloatRegister -{ - const char *name() const { - static const char *names[] = { - "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" - }; - return names[code]; - } - - int code; - - bool operator == (const FloatRegister &other) const { - return code == other.code; - } - bool operator != (const FloatRegister &other) const { - return code != other.code; - } -}; - -struct CPUFeatures -{ - CPUFeatures() - { - memset(this, 0, sizeof(*this)); - } - - bool fpu; - bool mmx; - bool sse; - bool sse2; - bool sse3; - bool ssse3; - bool sse4_1; - bool sse4_2; - bool avx; - bool avx2; -}; - -const Register eax = { 0 }; -const Register ecx = { 1 }; -const Register edx = { 2 }; -const Register ebx = { 3 }; -const Register esp = { 4 }; -const Register ebp = { 5 }; -const Register esi = { 6 }; -const Register edi = { 7 }; - -const Register r8_al = { 0 }; -const Register r8_cl = { 1 }; -const Register r8_dl = { 2 }; -const Register r8_bl = { 3 }; -const Register r8_ah = { 4 }; -const Register r8_ch = { 5 }; -const Register r8_dh = { 6 }; -const Register r8_bh = { 7 }; - -const FpuRegister st0 = { 0 }; -const FpuRegister st1 = { 1 }; -const FpuRegister st2 = { 2 }; -const FpuRegister st3 = { 3 }; -const FpuRegister st4 = { 4 }; -const FpuRegister st5 = { 5 }; -const FpuRegister st6 = { 6 }; -const FpuRegister st7 = { 7 }; - -const FloatRegister xmm0 = { 0 }; -const FloatRegister xmm1 = { 1 }; -const FloatRegister xmm2 = { 2 }; -const FloatRegister xmm3 = { 3 }; -const FloatRegister xmm4 = { 4 }; -const FloatRegister xmm5 = { 5 }; -const FloatRegister xmm6 = { 6 }; -const FloatRegister xmm7 = { 7 }; - -static const uint8_t kModeDisp0 = 0; -static const uint8_t kModeDisp8 = 1; -static const uint8_t kModeDisp32 = 2; -static const uint8_t kModeReg = 3; -static const uint8_t kNoIndex = 4; -static const uint8_t kSIB = 4; -static const uint8_t kRIP = 5; - -enum ConditionCode { - overflow, - no_overflow, - below, - not_below, - equal, - not_equal, - not_above, - above, - negative, - not_negative, - even_parity, - odd_parity, - less, - not_less, - not_greater, - greater, - - zero = equal, - not_zero = not_equal, - less_equal = not_greater, - below_equal = not_above, - greater_equal = not_less, - above_equal = not_below, - parity = even_parity, - not_parity = odd_parity -}; - -enum Scale { - NoScale, - ScaleTwo, - ScaleFour, - ScaleEight, - ScalePointer = ScaleFour -}; - -struct Operand -{ - friend class AssemblerX86; - - public: - Operand(Register reg, int32_t disp) { - if (reg == esp) { - // If the reg is esp, we need a SIB encoding. - if (disp == 0) - sib_disp0(NoScale, kNoIndex, reg.code); - else if (disp >= SCHAR_MIN && disp <= SCHAR_MAX) - sib_disp8(NoScale, kNoIndex, reg.code, disp); - else - sib_disp32(NoScale, kNoIndex, reg.code, disp); - } else if (disp == 0 && reg != ebp) { - // note, [ebp+0] is disp32/rip - modrm_disp0(reg.code); - } else if (disp >= SCHAR_MIN && disp <= SCHAR_MAX) { - modrm_disp8(reg.code, disp); - } else { - modrm_disp32(reg.code, disp); - } - } - - Operand(Register base, Scale scale, int32_t disp = 0) { - if (disp == 0 && base != ebp) - sib_disp0(scale, kNoIndex, base.code); - else if (disp >= SCHAR_MIN && disp <= SCHAR_MAX) - sib_disp8(scale, kNoIndex, base.code, disp); - else - sib_disp32(scale, kNoIndex, base.code, disp); - } - - Operand(Register base, Register index, Scale scale, int32_t disp = 0) { - assert(index.code != kNoIndex); - if (disp == 0 && base != ebp) - sib_disp0(scale, index.code, base.code); - else if (disp >= SCHAR_MIN && disp <= SCHAR_MAX) - sib_disp8(scale, index.code, base.code, disp); - else - sib_disp32(scale, index.code, base.code, disp); - } - - explicit Operand(ExternalAddress address) { - modrm(kModeDisp0, kRIP); - *reinterpret_cast(bytes_ + 1) = address.address(); - } - - bool isRegister() const { - return mode() == kModeReg; - } - bool isRegister(Register r) const { - return mode() == kModeReg && rm() == r.code; - } - int registerCode() const { - return rm(); - } - - uint8_t getByte(size_t index) const { - assert(index < length()); - return bytes_[index]; - } - - size_t length() const { - if (mode() == kModeDisp0 && rm() == kRIP) - return 5; - size_t sib = (mode() != kModeReg && rm() == kSIB); - if (mode() == kModeDisp32) - return 5 + sib; - if (mode() == kModeDisp8) - return 2 + sib; - return 1 + sib; - } - - private: - explicit Operand(Register reg) { - modrm(kModeReg, reg.code); - } - - void modrm(uint8_t mode, uint8_t rm) { - assert(mode <= 3); - assert(rm <= 7); - bytes_[0] = (mode << 6) | rm; - } - void modrm_disp0(uint8_t rm) { - modrm(kModeDisp0, rm); - } - void modrm_disp8(uint8_t rm, int8_t disp) { - modrm(kModeDisp8, rm); - bytes_[1] = disp; - } - void modrm_disp32(uint8_t rm, int32_t disp) { - modrm(kModeDisp32, rm); - *reinterpret_cast(bytes_ + 1) = disp; - } - void sib(uint8_t mode, Scale scale, uint8_t index, uint8_t base) { - modrm(mode, kSIB); - - assert(scale <= 3); - assert(index <= 7); - assert(base <= 7); - bytes_[1] = (uint8_t(scale) << 6) | (index << 3) | base; - } - void sib_disp0(Scale scale, uint8_t index, uint8_t base) { - sib(kModeDisp0, scale, index, base); - } - void sib_disp8(Scale scale, uint8_t index, uint8_t base, int8_t disp) { - sib(kModeDisp8, scale, index, base); - bytes_[2] = disp; - } - void sib_disp32(Scale scale, uint8_t index, uint8_t base, int32_t disp) { - sib(kModeDisp32, scale, index, base); - *reinterpret_cast(bytes_ + 2) = disp; - } - - private: - uint8_t rm() const { - return bytes_[0] & 7; - } - uint8_t mode() const { - return bytes_[0] >> 6; - } - - private: - uint8_t bytes_[6]; -}; - -class AssemblerX86 : public Assembler -{ - private: - // List of processor features; to be used, this must be filled in at - // startup. - static CPUFeatures X86Features; - - public: - static void SetFeatures(const CPUFeatures &features) { - X86Features = features; - } - static const CPUFeatures &Features() { - return X86Features; - } - - void movl(Register dest, Register src) { - emit1(0x89, src.code, dest.code); - } - void movl(Register dest, const Operand &src) { - emit1(0x8b, dest.code, src); - } - void movl(const Operand &dest, Register src) { - emit1(0x89, src.code, dest); - } - void movl(Register dest, int32_t imm) { - emit1(0xb8 + dest.code); - writeInt32(imm); - } - void movl(const Operand &dest, int32_t imm) { - if (dest.isRegister()) - emit1(0xb8 + dest.registerCode()); - else - emit1(0xc7, 0, dest); - writeInt32(imm); - } - void movw(const Operand &dest, Register src) { - emit1(0x89, src.code, dest); - } - void movw(Register dest, const Operand &src) { - emit1(0x8b, dest.code, src); - } - void movb(const Operand &dest, Register src) { - emit1(0x88, src.code, dest); - } - void movb(Register dest, const Operand &src) { - emit1(0x8a, dest.code, src); - } - void movzxb(Register dest, const Operand &src) { - emit2(0x0f, 0xb6, dest.code, src); - } - void movzxb(Register dest, const Register src) { - emit2(0x0f, 0xb6, dest.code, src.code); - } - void movzxw(Register dest, const Operand &src) { - emit2(0x0f, 0xb7, dest.code, src); - } - void movzxw(Register dest, const Register src) { - emit2(0x0f, 0xb7, dest.code, src.code); - } - - void lea(Register dest, const Operand &src) { - emit1(0x8d, dest.code, src); - } - - void xchgl(Register dest, Register src) { - if (src == eax) - emit1(0x90 + dest.code); - else if (dest == eax) - emit1(0x90 + src.code); - else - emit1(0x87, src.code, dest.code); - } - - void shll_cl(Register dest) { - shift_cl(dest.code, 4); - } - void shll(Register dest, uint8_t imm) { - shift_imm(dest.code, 4, imm); - } - void shll(const Operand &dest, uint8_t imm) { - shift_imm(dest, 4, imm); - } - void shrl_cl(Register dest) { - shift_cl(dest.code, 5); - } - void shrl(Register dest, uint8_t imm) { - shift_imm(dest.code, 5, imm); - } - void shrl(const Operand &dest, uint8_t imm) { - shift_imm(dest, 5, imm); - } - void sarl_cl(Register dest) { - shift_cl(dest.code, 7); - } - void sarl(Register dest, uint8_t imm) { - shift_imm(dest.code, 7, imm); - } - void sarl(const Operand &dest, uint8_t imm) { - shift_imm(dest, 7, imm); - } - - void cmpl(Register left, int32_t imm) { - alu_imm(7, imm, Operand(left)); - } - void cmpl(const Operand &left, int32_t imm) { - alu_imm(7, imm, left); - } - void cmpl(Register left, Register right) { - emit1(0x39, right.code, left.code); - } - void cmpl(const Operand &left, Register right) { - emit1(0x39, right.code, left); - } - void cmpl(Register left, const Operand &right) { - emit1(0x3b, left.code, right); - } - void andl(Register dest, int32_t imm) { - alu_imm(4, imm, Operand(dest)); - } - void andl(const Operand &dest, int32_t imm) { - alu_imm(4, imm, dest); - } - void andl(Register dest, Register src) { - emit1(0x21, src.code, dest.code); - } - void andl(const Operand &dest, Register src) { - emit1(0x21, src.code, dest); - } - void andl(Register dest, const Operand &src) { - emit1(0x23, dest.code, src); - } - void orl(Register dest, Register src) { - emit1(0x09, src.code, dest.code); - } - void orl(const Operand &dest, Register src) { - emit1(0x09, src.code, dest); - } - void orl(Register dest, const Operand &src) { - emit1(0x0b, dest.code, src); - } - void xorl(Register dest, Register src) { - emit1(0x31, src.code, dest.code); - } - void xorl(const Operand &dest, Register src) { - emit1(0x31, src.code, dest); - } - void xorl(Register dest, const Operand &src) { - emit1(0x33, dest.code, src); - } - - void subl(Register dest, Register src) { - emit1(0x29, src.code, dest.code); - } - void subl(const Operand &dest, Register src) { - emit1(0x29, src.code, dest); - } - void subl(Register dest, const Operand &src) { - emit1(0x2b, dest.code, src); - } - void subl(Register dest, int32_t imm) { - alu_imm(5, imm, Operand(dest)); - } - void subl(const Operand &dest, int32_t imm) { - alu_imm(5, imm, dest); - } - void addl(Register dest, Register src) { - emit1(0x01, src.code, dest.code); - } - void addl(const Operand &dest, Register src) { - emit1(0x01, src.code, dest); - } - void addl(Register dest, const Operand &src) { - emit1(0x03, dest.code, src); - } - void addl(Register dest, int32_t imm) { - alu_imm(0, imm, Operand(dest)); - } - void addl(const Operand &dest, int32_t imm) { - alu_imm(0, imm, dest); - } - - void imull(Register dest, const Operand &src) { - emit2(0x0f, 0xaf, dest.code, src); - } - void imull(Register dest, Register src) { - emit2(0x0f, 0xaf, dest.code, src.code); - } - void imull(Register dest, const Operand &src, int32_t imm) { - if (imm >= SCHAR_MIN && imm <= SCHAR_MAX) { - emit1(0x6b, dest.code, src); - *pos_++ = imm; - } else { - emit1(0x69, dest.code, src); - writeInt32(imm); - } - } - void imull(Register dest, Register src, int32_t imm) { - imull(dest, Operand(src), imm); - } - - void testl(const Operand &op1, Register op2) { - emit1(0x85, op2.code, op1); - } - void testl(Register op1, Register op2) { - emit1(0x85, op2.code, op1.code); - } - void set(ConditionCode cc, const Operand &dest) { - emit2(0x0f, 0x90 + uint8_t(cc), 0, dest); - } - void set(ConditionCode cc, Register dest) { - emit2(0x0f, 0x90 + uint8_t(cc), 0, dest.code); - } - void negl(Register srcdest) { - emit1(0xf7, 3, srcdest.code); - } - void negl(const Operand &srcdest) { - emit1(0xf7, 3, srcdest); - } - void notl(Register srcdest) { - emit1(0xf7, 2, srcdest.code); - } - void notl(const Operand &srcdest) { - emit1(0xf7, 2, srcdest); - } - void idivl(Register dividend) { - emit1(0xf7, 7, dividend.code); - } - void idivl(const Operand ÷nd) { - emit1(0xf7, 7, dividend); - } - - void ret() { - emit1(0xc3); - } - void cld() { - emit1(0xfc); - } - void push(Register reg) { - emit1(0x50 + reg.code); - } - void push(const Operand &src) { - if (src.isRegister()) - emit1(0x50 + src.registerCode()); - else - emit1(0xff, 6, src); - } - void push(int32_t imm) { - emit1(0x68); - writeInt32(imm); - } - void pop(Register reg) { - emit1(0x58 + reg.code); - } - void pop(const Operand &src) { - if (src.isRegister()) - emit1(0x58 + src.registerCode()); - else - emit1(0x8f, 0, src); - } - - void rep_movsb() { - emit2(0xf3, 0xa4); - } - void rep_movsd() { - emit2(0xf3, 0xa5); - } - void rep_stosd() { - emit2(0xf3, 0xab); - } - void breakpoint() { - emit1(0xcc); - } - - void fld32(const Operand &src) { - emit1(0xd9, 0, src); - } - void fild32(const Operand &src) { - emit1(0xdb, 0, src); - } - void fistp32(const Operand &dest) { - emit1(0xdb, 3, dest); - } - void fadd32(const Operand &src) { - emit1(0xd8, 0, src); - } - void fsub32(const Operand &src) { - emit1(0xd8, 4, src); - } - void fmul32(const Operand &src) { - emit1(0xd8, 1, src); - } - void fdiv32(const Operand &src) { - emit1(0xd8, 6, src); - } - void fstp32(const Operand &dest) { - emit1(0xd9, 3, dest); - } - void fstp(FpuRegister src) { - emit2(0xdd, 0xd8 + src.code); - } - void fldcw(const Operand &src) { - emit1(0xd9, 5, src); - } - void fstcw(const Operand &dest) { - emit2(0x9b, 0xd9, 7, dest); - } - void fsubr32(const Operand &src) { - emit1(0xd8, 5, src); - } - void fldz() { - emit2(0xd9, 0xee); - } - - // Compare st0 with stN. - void fucomip(FpuRegister other) { - emit2(0xdf, 0xe8 + other.code); - } - - // At least one argument of these forms must be st0. - void fadd32(FpuRegister dest, FpuRegister src) { - assert(dest == st0 || src == st0); - if (dest == st0) - emit2(0xd8, 0xc0 + dest.code); - else - emit2(0xdc, 0xc0 + src.code); - } - - void jmp32(Label *dest) { - emit1(0xe9); - emitJumpTarget(dest); - } - void jmp(Label *dest) { - int8_t d8; - if (canEmitSmallJump(dest, &d8)) { - emit2(0xeb, d8); - } else { - emit1(0xe9); - emitJumpTarget(dest); - } - } - void jmp(Register target) { - emit1(0xff, 4, target.code); - } - void jmp(const Operand &target) { - emit1(0xff, 4, target); - } - void j32(ConditionCode cc, Label *dest) { - emit2(0x0f, 0x80 + uint8_t(cc)); - emitJumpTarget(dest); - } - void j(ConditionCode cc, Label *dest) { - int8_t d8; - if (canEmitSmallJump(dest, &d8)) { - emit2(0x70 + uint8_t(cc), d8); - } else { - emit2(0x0f, 0x80 + uint8_t(cc)); - emitJumpTarget(dest); - } - } - void call(Label *dest) { - emit1(0xe8); - emitJumpTarget(dest); - } - void bind(Label *target) { - if (outOfMemory()) { - // If we ran out of memory, the code stream is potentially invalid and - // we cannot use the embedded linked list. - target->bind(pc()); - return; - } - - assert(!target->bound()); - uint32_t status = target->status(); - while (Label::More(status)) { - // Grab the offset. It should be at least a 1byte op + rel32. - uint32_t offset = Label::ToOffset(status); - assert(offset >= 5); - - // Grab the delta from target to pc. - ptrdiff_t delta = pos_ - (buffer() + offset); - assert(delta >= INT_MIN && delta <= INT_MAX); - - int32_t *p = reinterpret_cast(buffer() + offset - 4); - status = *p; - *p = delta; - } - target->bind(pc()); - } - - void bind(DataLabel *address) { - if (outOfMemory()) - return; - if (address->used()) { - uint32_t offset = DataLabel::ToOffset(address->status()); - *reinterpret_cast(buffer() + offset - 4) = position() - int32_t(offset); - } - address->bind(pc()); - } - void movl(Register dest, DataLabel *src) { - emit1(0xb8 + dest.code); - if (src->bound()) { - writeInt32(int32_t(src->offset()) - (position() + 4)); - } else { - writeInt32(0xabcdef0); - src->use(pc()); - } - if (!local_refs_.append(pc())) - outOfMemory_ = true; - } - void emit_absolute_address(Label *address) { - if (address->bound()) - writeUint32(int32_t(address->offset()) - (position() + 4)); - else - writeUint32(address->addPending(position() + 4)); - if (!local_refs_.append(pc())) - outOfMemory_ = true; - } - - void call(Register target) { - emit1(0xff, 2, target.code); - } - void call(const Operand &target) { - emit1(0xff, 2, target); - } - void call(ExternalAddress address) { - emit1(0xe8); - writeInt32(address.value()); - if (!external_refs_.append(pc())) - outOfMemory_ = true; - } - void jmp(ExternalAddress address) { - assert(sizeof(address) == sizeof(int32_t)); - emit1(0xe9); - writeInt32(address.value()); - if (!external_refs_.append(pc())) - outOfMemory_ = true; - } - - void cpuid() { - emit2(0x0f, 0xa2); - } - - - // SSE operations can only be used if the feature detection function has - // been run *and* detected the appropriate level of functionality. - void movss(FloatRegister dest, const Operand &src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x10, dest.code, src); - } - void cvttss2si(Register dest, Register src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x2c, dest.code, src.code); - } - void cvttss2si(Register dest, const Operand &src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x2c, dest.code, src); - } - void cvtss2si(Register dest, Register src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x2d, dest.code, src.code); - } - void cvtss2si(Register dest, const Operand &src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x2d, dest.code, src); - } - void cvtsi2ss(FloatRegister dest, Register src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x2a, dest.code, src.code); - } - void cvtsi2ss(FloatRegister dest, const Operand &src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x2a, dest.code, src); - } - void addss(FloatRegister dest, const Operand &src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x58, dest.code, src); - } - void subss(FloatRegister dest, const Operand &src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x5c, dest.code, src); - } - void mulss(FloatRegister dest, const Operand &src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x59, dest.code, src); - } - void divss(FloatRegister dest, const Operand &src) { - assert(Features().sse); - emit3(0xf3, 0x0f, 0x5e, dest.code, src); - } - void xorps(FloatRegister dest, FloatRegister src) { - assert(Features().sse); - emit2(0x0f, 0x57, src.code, dest.code); - } - - void ucomiss(FloatRegister left, FloatRegister right) { - emit2(0x0f, 0x2e, right.code, left.code); - } - void ucomiss(const Operand &left, FloatRegister right) { - emit2(0x0f, 0x2e, right.code, left); - } - - // SSE2-only instructions. - void movd(Register dest, FloatRegister src) { - assert(Features().sse2); - emit3(0x66, 0x0f, 0x7e, dest.code, src.code); - } - void movd(Register dest, const Operand &src) { - assert(Features().sse2); - emit3(0x66, 0x0f, 0x7e, dest.code, src); - } - - static void PatchRel32Absolute(uint8_t *ip, void *ptr) { - int32_t delta = uint32_t(ptr) - uint32_t(ip); - *reinterpret_cast(ip - 4) = delta; - } - - void emitToExecutableMemory(void *code) { - assert(!outOfMemory()); - - // Relocate anything we emitted as rel32 with an external pointer. - uint8_t *base = reinterpret_cast(code); - memcpy(base, buffer(), length()); - for (size_t i = 0; i < external_refs_.length(); i++) { - size_t offset = external_refs_[i]; - PatchRel32Absolute(base + offset, *reinterpret_cast(base + offset - 4)); - } - - // Relocate everything we emitted as an abs32 with an internal offset. Note - // that in the code stream, we use relative offsets so we can use both Label - // and DataLabel. - for (size_t i = 0; i < local_refs_.length(); i++) { - size_t offset = local_refs_[i]; - int32_t delta = *reinterpret_cast(base + offset - 4); - *reinterpret_cast(base + offset - 4) = base + offset + delta; - } - } - - void align(uint32_t bytes) { - int32_t delta = (pc() & ~(bytes - 1)) + bytes - pc(); - for (int32_t i = 0; i < delta; i++) - emit1(0xcc); - } - - private: - bool canEmitSmallJump(Label *dest, int8_t *deltap) { - if (!dest->bound()) - return false; - - // All small jumps are assumed to be 2 bytes. - ptrdiff_t delta = ptrdiff_t(dest->offset()) - (position() + 2); - if (delta < SCHAR_MIN || delta > SCHAR_MAX) - return false; - *deltap = delta; - return true; - } - void emitJumpTarget(Label *dest) { - if (dest->bound()) { - ptrdiff_t delta = ptrdiff_t(dest->offset()) - (position() + 4); - assert(delta >= INT_MIN && delta <= INT_MAX); - writeInt32(delta); - } else { - writeUint32(dest->addPending(position() + 4)); - } - } - - void emit(uint8_t reg, const Operand &operand) { - *pos_++ = operand.getByte(0) | (reg << 3); - size_t length = operand.length(); - for (size_t i = 1; i < length; i++) - *pos_++ = operand.getByte(i); - } - - void emit1(uint8_t opcode) { - ensureSpace(); - *pos_++ = opcode; - } - void emit1(uint8_t opcode, uint8_t reg, uint8_t opreg) { - ensureSpace(); - assert(reg <= 7); - assert(opreg <= 7); - *pos_++ = opcode; - *pos_++ = (kModeReg << 6) | (reg << 3) | opreg; - } - void emit1(uint8_t opcode, uint8_t reg, const Operand &operand) { - ensureSpace(); - assert(reg <= 7); - *pos_++ = opcode; - emit(reg, operand); - } - - void emit2(uint8_t prefix, uint8_t opcode) { - ensureSpace(); - *pos_++ = prefix; - *pos_++ = opcode; - } - void emit2(uint8_t prefix, uint8_t opcode, uint8_t reg, uint8_t opreg) { - emit2(prefix, opcode); - assert(reg <= 7); - *pos_++ = (kModeReg << 6) | (reg << 3) | opreg; - } - void emit2(uint8_t prefix, uint8_t opcode, uint8_t reg, const Operand &operand) { - emit2(prefix, opcode); - emit(reg, operand); - } - - void emit3(uint8_t prefix1, uint8_t prefix2, uint8_t opcode) { - ensureSpace(); - *pos_++ = prefix1; - *pos_++ = prefix2; - *pos_++ = opcode; - } - void emit3(uint8_t prefix1, uint8_t prefix2, uint8_t opcode, uint8_t reg, uint8_t opreg) { - emit3(prefix1, prefix2, opcode); - assert(reg <= 7); - *pos_++ = (kModeReg << 6) | (reg << 3) | opreg; - } - void emit3(uint8_t prefix1, uint8_t prefix2, uint8_t opcode, uint8_t reg, const Operand &operand) { - emit3(prefix1, prefix2, opcode); - emit(reg, operand); - } - - template - void shift_cl(const T &t, uint8_t r) { - emit1(0xd3, r, t); - } - - template - void shift_imm(const T &t, uint8_t r, int32_t imm) { - if (imm == 1) { - emit1(0xd1, r, t); - } else { - emit1(0xc1, r, t); - *pos_++ = imm & 0x1F; - } - } - void alu_imm(uint8_t r, int32_t imm, const Operand &operand) { - if (imm >= SCHAR_MIN && imm <= SCHAR_MAX) { - emit1(0x83, r, operand); - *pos_++ = uint8_t(imm & 0xff); - } else if (operand.isRegister(eax)) { - emit1(0x05 | (r << 3)); - writeInt32(imm); - } else { - emit1(0x81, r, operand); - writeInt32(imm); - } - } - - private: - ke::Vector external_refs_; - ke::Vector local_refs_; -}; - -#endif // _include_sourcepawn_assembler_x86_h__ - diff --git a/public/jit/x86/macro-assembler-x86.h b/public/jit/x86/macro-assembler-x86.h deleted file mode 100644 index 4d67c74c..00000000 --- a/public/jit/x86/macro-assembler-x86.h +++ /dev/null @@ -1,104 +0,0 @@ -/** - * vim: set ts=8 sts=2 sw=2 tw=99 et: - * ============================================================================= - * SourcePawn JIT SDK - * 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 . - * - * 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 . - * - * Version: $Id$ - */ -#ifndef _include_sourcepawn_macroassembler_x86h__ -#define _include_sourcepawn_macroassembler_x86h__ - -#include -#include -#include -#include - -class MacroAssemblerX86 : public AssemblerX86 -{ - public: - static void GenerateFeatureDetection(MacroAssemblerX86 &masm) { - masm.push(ebp); - masm.movl(ebp, esp); - masm.push(ebx); - { - // Get ECX, EDX feature bits at the first CPUID level. - masm.movl(eax, 1); - masm.cpuid(); - masm.movl(eax, Operand(ebp, 8)); - masm.movl(Operand(eax, 0), ecx); - masm.movl(eax, Operand(ebp, 12)); - masm.movl(Operand(eax, 0), edx); - } - - // Zero out bits we're not guaranteed to get. - masm.movl(eax, Operand(ebp, 16)); - masm.movl(Operand(eax, 0), 0); - - Label skip_level_7; - { - // Get EBX feature bits at 7th CPUID level. - masm.movl(eax, 0); - masm.cpuid(); - masm.cmpl(eax, 7); - masm.j(below, &skip_level_7); - masm.movl(eax, 7); - masm.movl(ecx, 0); - masm.cpuid(); - masm.movl(eax, Operand(ebp, 16)); - masm.movl(Operand(eax, 0), ebx); - } - masm.bind(&skip_level_7); - - masm.pop(ebx); - masm.pop(ebp); - masm.ret(); - } - - static void RunFeatureDetection(void *code) { - typedef void (*fn_t)(int *reg_ecx, int *reg_edx, int *reg_ebx); - - int reg_ecx, reg_edx, reg_ebx; - ((fn_t)code)(®_ecx, ®_edx, ®_ebx); - - CPUFeatures features; - features.fpu = !!(reg_edx & (1 << 0)); - features.mmx = !!(reg_edx & (1 << 23)); - features.sse = !!(reg_edx & (1 << 25)); - features.sse2 = !!(reg_edx & (1 << 26)); - features.sse3 = !!(reg_ecx & (1 << 0)); - features.ssse3 = !!(reg_ecx & (1 << 9)); - features.sse4_1 = !!(reg_ecx & (1 << 19)); - features.sse4_2 = !!(reg_ecx & (1 << 20)); - features.avx = !!(reg_ecx & (1 << 28)); - features.avx2 = !!(reg_ebx & (1 << 5)); - SetFeatures(features); - } - - private: -}; - -#endif // _include_sourcepawn_macroassembler_x86h__ - diff --git a/public/sample_ext/msvc10/sdk.vcxproj b/public/sample_ext/msvc10/sdk.vcxproj index 81731bd6..cf26cda0 100644 --- a/public/sample_ext/msvc10/sdk.vcxproj +++ b/public/sample_ext/msvc10/sdk.vcxproj @@ -447,7 +447,7 @@ Disabled - ..;..\sdk;..\..;..\..\sourcepawn;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) true EnableFastChecks @@ -472,7 +472,7 @@ Speed - ..;..\sdk;..\..;..\..\sourcepawn;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -499,7 +499,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) true EnableFastChecks @@ -526,7 +526,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -553,7 +553,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) true EnableFastChecks @@ -580,7 +580,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -607,7 +607,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) true EnableFastChecks @@ -634,7 +634,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -661,7 +661,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) true EnableFastChecks @@ -688,7 +688,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -715,7 +715,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) true EnableFastChecks @@ -742,7 +742,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -769,7 +769,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=4;%(PreprocessorDefinitions) true EnableFastChecks @@ -796,7 +796,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=4;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -823,7 +823,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=5;%(PreprocessorDefinitions) true EnableFastChecks @@ -850,7 +850,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=5;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -877,7 +877,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=8;%(PreprocessorDefinitions) true EnableFastChecks @@ -904,7 +904,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=8;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -931,7 +931,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=9;%(PreprocessorDefinitions) true EnableFastChecks @@ -958,7 +958,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=10;%(PreprocessorDefinitions) true EnableFastChecks @@ -985,7 +985,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=9;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -1012,7 +1012,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=10;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -1039,7 +1039,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=12;%(PreprocessorDefinitions) true EnableFastChecks @@ -1066,7 +1066,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=12;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -1093,7 +1093,7 @@ /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) true EnableFastChecks @@ -1120,7 +1120,7 @@ /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + ..;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) MultiThreaded NotSet @@ -1145,12 +1145,12 @@ - + - - + + diff --git a/public/sample_ext/msvc10/sdk.vcxproj.filters b/public/sample_ext/msvc10/sdk.vcxproj.filters index 69a7e8d6..9a0b4b1e 100644 --- a/public/sample_ext/msvc10/sdk.vcxproj.filters +++ b/public/sample_ext/msvc10/sdk.vcxproj.filters @@ -21,7 +21,7 @@ Source Files - + SourceMod SDK @@ -29,10 +29,10 @@ Header Files - + SourceMod SDK - + SourceMod SDK diff --git a/public/sample_ext/msvc12/sdk.sln b/public/sample_ext/msvc12/sdk.sln new file mode 100644 index 00000000..7fd0b227 --- /dev/null +++ b/public/sample_ext/msvc12/sdk.sln @@ -0,0 +1,85 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdk", "sdk.vcxproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug - CSGO|Win32 = Debug - CSGO|Win32 + Debug - Alien Swarm|Win32 = Debug - Alien Swarm|Win32 + Debug - CSS|Win32 = Debug - CSS|Win32 + Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 + Debug - Episode 1|Win32 = Debug - Episode 1|Win32 + Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 + Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 + Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 + Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 + Debug - Orange Box|Win32 = Debug - Orange Box|Win32 + Debug|Win32 = Debug|Win32 + Release - CSGO|Win32 = Release - CSGO|Win32 + Release - CSS|Win32 = Release - CSS|Win32 + Release - Alien Swarm|Win32 = Release - Alien Swarm|Win32 + Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 + Release - Episode 1|Win32 = Release - Episode 1|Win32 + Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 + Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 + Release - Old Metamod|Win32 = Release - Old Metamod|Win32 + Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 + Release - Orange Box|Win32 = Release - Orange Box|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Alien Swarm|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Alien Swarm|Win32.Build.0 = Debug - Alien Swarm|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - CSGO|Win32.ActiveCfg = Debug - CSGO|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - CSGO|Win32.Build.0 = Debug - CSGO|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - CSS|Win32.ActiveCfg = Debug - CSS|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - CSS|Win32.Build.0 = Debug - CSS|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Alien Swarm|Win32.ActiveCfg = Release - Alien Swarm|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Alien Swarm|Win32.Build.0 = Release - Alien Swarm|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CSGO|Win32.ActiveCfg = Release - CSGO|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CSGO|Win32.Build.0 = Release - CSGO|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CSS|Win32.ActiveCfg = Release - CSS|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CSS|Win32.Build.0 = Release - CSS|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/extensions/sdkhooks/msvc10/sdkhooks.vcxproj b/public/sample_ext/msvc12/sdk.vcxproj similarity index 57% rename from extensions/sdkhooks/msvc10/sdkhooks.vcxproj rename to public/sample_ext/msvc12/sdk.vcxproj index 61250e43..571bfdf6 100644 --- a/extensions/sdkhooks/msvc10/sdkhooks.vcxproj +++ b/public/sample_ext/msvc12/sdk.vcxproj @@ -1,1318 +1,1182 @@ - - - - - Debug - Bloody Good Time - Win32 - - - Debug - CS GO - Win32 - - - Debug - CSS - Win32 - - - Debug - Dark Messiah - Win32 - - - Debug - Episode 1 - Win32 - - - Debug - EYE - Win32 - - - Debug - Left 4 Dead 2 - Win32 - - - Debug - Left 4 Dead - Win32 - - - Debug - Old Metamod - Win32 - - - Debug - Orange Box Valve - Win32 - - - Debug - Orange Box - Win32 - - - Debug - Swarm - Win32 - - - Release - Bloody Good Time - Win32 - - - Release - CS GO - Win32 - - - Release - CSS - Win32 - - - Release - Dark Messiah - Win32 - - - Release - Episode 1 - Win32 - - - Release - EYE - Win32 - - - Release - Left 4 Dead 2 - Win32 - - - Release - Left 4 Dead - Win32 - - - Release - Old Metamod - Win32 - - - Release - Orange Box Valve - Win32 - - - Release - Orange Box - Win32 - - - Release - Swarm - Win32 - - - - {F35CF30D-5C8E-4A95-9F8C-E5A80A124432} - sdk - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - true - true - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - false - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - sdkhooks.ext.2.ep2v - - - sdkhooks.ext.2.css - - - sdkhooks.ext.2.bgt - - - sdkhooks.ext.2.csgo - - - sdkhooks.ext.2.darkm - - - sdkhooks.ext.2.eye - - - sdkhooks.ext.2.ep1 - - - sdkhooks.ext.2.l4d - - - sdkhooks.ext.2.l4d2 - - - sdkhooks.ext.1.ep1 - - - sdkhooks.ext.2.ep2 - - - sdkhooks.ext.2.ep2v - - - sdkhooks.ext.2.css - - - sdkhooks.ext.2.swarm - - - sdkhooks.ext.2.bgt - - - sdkhooks.ext.2.csgo - - - sdkhooks.ext.2.darkm - - - sdkhooks.ext.2.eye - - - sdkhooks.ext.2.ep1 - - - sdkhooks.ext.2.l4d - - - sdkhooks.ext.2.l4d2 - - - sdkhooks.ext.1.ep1 - - - sdkhooks.ext.2.ep2 - - - sdkhooks.ext.2.swarm - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK)\game_shared;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK)\game_shared;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKOB)\game\shared;$(HL2SDKOB)\common;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\toolframework;$(HL2SDKOB)\public\mathlib;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;$(HL2SDKOB)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKOB)\game\shared;$(HL2SDKOB)\common;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\toolframework;$(HL2SDKOB)\public\mathlib;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;$(HL2SDKOB)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK)\game_shared;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - - - ..\..\..\public - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK)\game_shared;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\mathlib;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;$(HL2SDK)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKL4D)\game\shared;$(HL2SDKL4D)\common;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\toolframework;$(HL2SDKL4D)\public\mathlib;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;$(HL2SDKL4D)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKL4D)\game\shared;$(HL2SDKL4D)\common;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\toolframework;$(HL2SDKL4D)\public\mathlib;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;$(HL2SDKL4D)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-DARKM)\game_shared;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\mathlib;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;$(HL2SDK-DARKM)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-DARKM)\game_shared;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\mathlib;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;$(HL2SDK-DARKM)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKOBVALVE)\common;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\toolframework;$(HL2SDKOBVALVE)\public\mathlib;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(HL2SDKOBVALVE)\game\shared;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;$(HL2SDKOBVALVE)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKCSS)\common;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\toolframework;$(HL2SDKCSS)\public\mathlib;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(HL2SDKCSS)\game\shared;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;$(HL2SDKCSS)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Full - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKOBVALVE)\common;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\mathlib;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(HL2SDKOBVALVE)\game\shared;$(HL2SDKOBVALVE)\public\toolframework;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;$(HL2SDKOBVALVE)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Full - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKCSS)\common;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\mathlib;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(HL2SDKCSS)\game\shared;$(HL2SDKCSS)\public\toolframework;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;$(HL2SDKCSS)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-EYE)\common;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\toolframework;$(HL2SDK-EYE)\public\mathlib;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(HL2SDK-EYE)\game\shared;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=5;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;$(HL2SDK-EYE)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Full - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-EYE)\common;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\mathlib;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(HL2SDK-EYE)\game\shared;$(HL2SDK-EYE)\public\toolframework;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=5;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;$(HL2SDK-EYE)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKL4D2)\common;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\toolframework;$(HL2SDKL4D2)\public\mathlib;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\game\shared;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKL4D2)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKL4D2)\game\shared;$(HL2SDKL4D2)\common;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\toolframework;$(HL2SDKL4D2)\public\mathlib;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;$(HL2SDKL4D2)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-BGT)\game\shared;$(HL2SDK-BGT)\common;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\toolframework;$(HL2SDK-BGT)\public\mathlib;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=4;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;$(HL2SDK-BGT)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-BGT)\game\shared;$(HL2SDK-BGT)\common;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\toolframework;$(HL2SDK-BGT)\public\mathlib;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=4;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;$(HL2SDK-BGT)\lib\public\mathlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-SWARM)\common;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\toolframework;$(HL2SDK-SWARM)\public\mathlib;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\game\shared;$(HL2SDK-SWARM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=10;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;$(HL2SDK-SWARM)\lib\public\mathlib.lib;$(HL2SDK-SWARM)\lib\public\interfaces.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDK-SWARM)\common;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\toolframework;$(HL2SDK-SWARM)\public\mathlib;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(HL2SDK-SWARM)\game\shared;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=10;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;$(HL2SDK-SWARM)\lib\public\mathlib.lib;$(HL2SDK-SWARM)\lib\public\interfaces.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Disabled - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKCSGO)\common;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\toolframework;$(HL2SDKCSGO)\public\mathlib;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\game\shared;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\mathlib.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 - Speed - ..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;$(HL2SDKCSGO)\common;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\toolframework;$(HL2SDKCSGO)\public\mathlib;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(HL2SDKCSGO)\game\shared;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=12;COMPILER_MSVC;COMPILER_MSVC32;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - true - - - BINARY_NAME="\"$(TargetFileName)\"";%(PreprocessorDefinitions) - ..\..\..\public - - - $(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\mathlib.lib;$(HL2SDKCSGO)\lib\public\interfaces.lib;%(AdditionalDependencies) - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\extensions" - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug - CSGO + Win32 + + + Debug - CSS + Win32 + + + Debug - Alien Swarm + Win32 + + + Debug - Dark Messiah + Win32 + + + Debug - Episode 1 + Win32 + + + Debug - Left 4 Dead 2 + Win32 + + + Debug - Left 4 Dead + Win32 + + + Debug - Old Metamod + Win32 + + + Debug - Orange Box Valve + Win32 + + + Debug - Orange Box + Win32 + + + Debug - Orange Box + Win32 + + + Debug - Orange Box + Win32 + + + Debug + Win32 + + + Release - CSGO + Win32 + + + Release - CSS + Win32 + + + Release - Alien Swarm + Win32 + + + Release - Dark Messiah + Win32 + + + Release - Episode 1 + Win32 + + + Release - Left 4 Dead 2 + Win32 + + + Release - Left 4 Dead + Win32 + + + Release - Old Metamod + Win32 + + + Release - Orange Box Valve + Win32 + + + Release - Orange Box + Win32 + + + Release - Bloody Good Time + Win32 + + + Release - EYE + Win32 + + + Release + Win32 + + + + {B3E797CF-4E77-4C9D-B8A8-7589B6902206} + sdk + Win32Proj + + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + true + v120 + + + DynamicLibrary + MultiByte + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + true + false + true + false + true + false + true + false + true + false + true + false + true + false + true + false + true + true + true + false + false + false + true + false + true + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + sample.ext.2.darkm + sample.ext.2.ep1 + sample.ext.2.l4d2 + sample.ext.2.csgo + sample.ext.2.css + sample.ext.2.swarm + sample.ext.2.l4d + sample.ext.1.ep1 + sample.ext.2.ep2v + sample.ext.2.ep2 + sample.ext.2.bgt + sample.ext.2.eye + sample.ext + sample.ext.2.darkm + sample.ext.2.ep1 + sample.ext.2.l4d2 + sample.ext.2.csgo + sample.ext.2.css + sample.ext.2.swarm + sample.ext.2.l4d + sample.ext.1.ep1 + sample.ext.2.ep2v + sample.ext.2.ep2 + sample.ext.2.bgt + sample.ext.2.eye + sample.ext + + + + Disabled + ..;..\..;..\..\sourcepawn;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + Speed + ..;..\..;..\..\sourcepawn;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + + + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDKCSS)\public;$(HL2SDKCSS)\public\engine;$(HL2SDKCSS)\public\game\server;$(HL2SDKCSS)\public\tier0;$(HL2SDKCSS)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDKCSS)\lib\public\tier0.lib;$(HL2SDKCSS)\lib\public\tier1.lib;$(HL2SDKCSS)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=4;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDK-BGT)\public;$(HL2SDK-BGT)\public\engine;$(HL2SDK-BGT)\public\game\server;$(HL2SDK-BGT)\public\tier0;$(HL2SDK-BGT)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=4;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDK-BGT)\lib\public\tier0.lib;$(HL2SDK-BGT)\lib\public\tier1.lib;$(HL2SDK-BGT)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=5;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDK-EYE)\public;$(HL2SDK-EYE)\public\engine;$(HL2SDK-EYE)\public\game\server;$(HL2SDK-EYE)\public\tier0;$(HL2SDK-EYE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=5;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDK-EYE)\lib\public\tier0.lib;$(HL2SDK-EYE)\lib\public\tier1.lib;$(HL2SDK-EYE)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=8;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=8;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=9;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=10;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDK-SWARM)\lib\public\interfaces.lib;$(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=9;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=10;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDK-SWARM)\lib\public\interfaces.lib;$(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=12;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDKCSGO)\lib\public\interfaces.lib;$(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=12;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDKCSGO)\lib\public\interfaces.lib;$(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Disabled + ..;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotSet + false + + + Level3 + EditAndContinue + + + $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + Windows + false + + + MachineX86 + + + + + /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_CSS=6 /D SE_ORANGEBOXVALVE=7 /D SE_LEFT4DEAD=8 /D SE_LEFT4DEAD2=9 /D SE_ALIENSWARM=10 /D SE_PORTAL2=11 /D SE_CSGO=12 + Speed + ..;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) + MultiThreaded + NotSet + false + + + Level3 + ProgramDatabase + + + $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;%(AdditionalDependencies) + LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + false + + + MachineX86 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/extensions/regex/msvc10/regex.vcxproj.filters b/public/sample_ext/msvc12/sdk.vcxproj.filters similarity index 68% rename from extensions/regex/msvc10/regex.vcxproj.filters rename to public/sample_ext/msvc12/sdk.vcxproj.filters index c5affa05..23a8cdd7 100644 --- a/extensions/regex/msvc10/regex.vcxproj.filters +++ b/public/sample_ext/msvc12/sdk.vcxproj.filters @@ -1,53 +1,39 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {31958233-BB2D-4e41-A8F9-CE8A4684F436} - - - - - Source Files - - - Source Files - - - SourceMod SDK - - - - - Header Files - - - Header Files - - - Header Files - - - SourceMod SDK - - - SourceMod SDK - - - - - Resource Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + {31958233-BB2D-4e41-A8F9-CE8A4684F436} + + + + + Source Files + + + SourceMod SDK + + + + + Header Files + + + SourceMod SDK + + + SourceMod SDK + + \ No newline at end of file diff --git a/public/sample_ext/msvc8/sdk.vcproj b/public/sample_ext/msvc8/sdk.vcproj index 08f36b3e..16d2b2f5 100644 --- a/public/sample_ext/msvc8/sdk.vcproj +++ b/public/sample_ext/msvc8/sdk.vcproj @@ -40,7 +40,7 @@ diff --git a/public/sample_ext/msvc9/sdk.vcproj b/public/sample_ext/msvc9/sdk.vcproj index afa91562..627f85c5 100644 --- a/public/sample_ext/msvc9/sdk.vcproj +++ b/public/sample_ext/msvc9/sdk.vcproj @@ -41,7 +41,7 @@ diff --git a/public/sample_ext/smsdk_config.h b/public/sample_ext/smsdk_config.h index 693afed9..e4b49d87 100644 --- a/public/sample_ext/smsdk_config.h +++ b/public/sample_ext/smsdk_config.h @@ -76,7 +76,6 @@ //#define SMEXT_ENABLE_TEXTPARSERS //#define SMEXT_ENABLE_USERMSGS //#define SMEXT_ENABLE_TRANSLATOR -//#define SMEXT_ENABLE_NINVOKE //#define SMEXT_ENABLE_ROOTCONSOLEMENU #endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ diff --git a/public/sm_namehashset.h b/public/sm_namehashset.h index 85edd1cc..5e6fbe95 100644 --- a/public/sm_namehashset.h +++ b/public/sm_namehashset.h @@ -29,6 +29,8 @@ * Version: $Id$ */ +#include + #ifndef _include_sourcemod_namehashset_h_ #define _include_sourcemod_namehashset_h_ @@ -117,14 +119,10 @@ public: return table_.findForAdd(aKey); } - void add(Insert &i, const T &value) + template + bool add(Insert &i, U &&value) { - return table_.add(i, value); - } - - void add(Insert &i, ke::Moveable value) - { - return table_.add(i, value); + return table_.add(i, ke::Forward(value)); } bool retrieve(const char *aKey, T *value) @@ -137,22 +135,14 @@ public: return true; } - bool insert(const char *aKey, const T &value) + template + bool insert(const char *aKey, U &&value) { CharsAndLength key(aKey); Insert i = table_.findForAdd(key); if (i.found()) return false; - return table_.add(i, value); - } - - bool insert(const char *aKey, ke::Moveable value) - { - CharsAndLength key(aKey); - Insert i = table_.findForAdd(key); - if (i.found()) - return false; - return table_.add(i, value); + return table_.add(i, ke::Forward(value)); } bool contains(const char *aKey) diff --git a/public/smsdk_ext.cpp b/public/smsdk_ext.cpp index d4e9b4e3..ecb73889 100644 --- a/public/smsdk_ext.cpp +++ b/public/smsdk_ext.cpp @@ -97,9 +97,6 @@ IUserMessages *usermsgs = NULL; #if defined SMEXT_ENABLE_TRANSLATOR ITranslator *translator = NULL; #endif -#if defined SMEXT_ENABLE_NINVOKE -INativeInterface *ninvoke = NULL; -#endif #if defined SMEXT_ENABLE_ROOTCONSOLEMENU IRootConsole *rootconsole = NULL; #endif @@ -191,9 +188,6 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #if defined SMEXT_ENABLE_TRANSLATOR SM_GET_IFACE(TRANSLATOR, translator); #endif -#if defined SMEXT_ENABLE_NINVOKE - SM_GET_IFACE(NINVOKE, ninvoke); -#endif #if defined SMEXT_ENABLE_ROOTCONSOLEMENU SM_GET_IFACE(ROOTCONSOLE, rootconsole); #endif @@ -307,8 +301,10 @@ ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */ SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */ ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */ +#ifndef META_NO_HL2SDK IVEngineServer *engine = NULL; /**< IVEngineServer pointer */ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ +#endif /** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) @@ -321,14 +317,14 @@ SMM_API void *PL_EXPOSURE(const char *name, int *code) { if (code) { - *code = IFACE_OK; + *code = META_IFACE_OK; } return static_cast(g_pExtensionIface); } if (code) { - *code = IFACE_FAILED; + *code = META_IFACE_FAILED; } return NULL; @@ -338,6 +334,7 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { PLUGIN_SAVEVARS(); +#ifndef META_NO_HL2SDK #if !defined METAMOD_PLAPI_VERSION GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); @@ -345,6 +342,7 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); #endif +#endif //META_NO_HL2SDK m_SourceMMLoaded = true; diff --git a/public/smsdk_ext.h b/public/smsdk_ext.h index 9e86aa12..922e2f2f 100644 --- a/public/smsdk_ext.h +++ b/public/smsdk_ext.h @@ -91,16 +91,15 @@ #if defined SMEXT_ENABLE_TRANSLATOR #include #endif -#if defined SMEXT_ENABLE_NINVOKE -#include -#endif #if defined SMEXT_ENABLE_ROOTCONSOLEMENU #include #endif #if defined SMEXT_CONF_METAMOD #include +#ifndef META_NO_HL2SDK #include +#endif //META_NO_HL2SDK #endif #if !defined METAMOD_PLAPI_VERSION @@ -308,17 +307,16 @@ extern IUserMessages *usermsgs; #if defined SMEXT_ENABLE_TRANSLATOR extern ITranslator *translator; #endif -#if defined SMEXT_ENABLE_NINVOKE -extern INativeInterface *ninvoke; -#endif #if defined SMEXT_ENABLE_ROOTCONSOLEMENU extern IRootConsole *rootconsole; #endif #if defined SMEXT_CONF_METAMOD PLUGIN_GLOBALVARS(); +#ifndef META_NO_HL2SDK extern IVEngineServer *engine; extern IServerGameDLL *gamedll; +#endif //META_NO_HL2SDK #endif /** Creates a SourceMod interface macro pair */ diff --git a/public/sourcepawn/sp_typeutil.h b/public/sourcepawn/sp_typeutil.h deleted file mode 100644 index 78eb0f5a..00000000 --- a/public/sourcepawn/sp_typeutil.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * vim: set ts=4 : - * ============================================================================= - * SourcePawn - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_ -#define _INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_ - -/** - * @file sp_typeutil.h - * @brief Defines type utility functions. - */ - -#include "sp_vm_types.h" - -/** - * @brief Reinterpret-casts a float to a cell (requires -fno-strict-aliasing for GCC). - * - * @param val Float value. - * @return Cell typed version. - */ -inline cell_t sp_ftoc(float val) -{ - return *(cell_t *)&val; -} - -/** - * @brief Reinterpret-casts a cell to a float (requires -fno-strict-aliasing for GCC). - * - * @param val Cell-packed float value. - * @return Float typed version. - */ -inline float sp_ctof(cell_t val) -{ - return *(float *)&val; -} - -#endif //_INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_ - diff --git a/public/sourcepawn/sp_vm_api.h b/public/sourcepawn/sp_vm_api.h deleted file mode 100644 index 0b9a2aac..00000000 --- a/public/sourcepawn/sp_vm_api.h +++ /dev/null @@ -1,1367 +0,0 @@ -/** - * vim: set ts=4 sw=4 tw=99 noet : - * ============================================================================= - * SourcePawn - * Copyright (C) 2004-2009 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 . - * - * 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 . - */ - -#ifndef _INCLUDE_SOURCEPAWN_VM_API_H_ -#define _INCLUDE_SOURCEPAWN_VM_API_H_ - -/** - * @file sp_vm_api.h - * @brief Contains all of the object structures used in the SourcePawn API. - */ - -#include -#include "sp_vm_types.h" - -/** SourcePawn Engine API Version */ -#define SOURCEPAWN_ENGINE_API_VERSION 4 -#define SOURCEPAWN_ENGINE2_API_VERSION 6 - -#if !defined SOURCEMOD_BUILD -#define SOURCEMOD_BUILD -#endif - -#if defined SOURCEMOD_BUILD -namespace SourceMod -{ - struct IdentityToken_t; -}; -#endif - -struct sp_context_s; -typedef struct sp_context_s sp_context_t; - -namespace SourcePawn -{ - class IVirtualMachine; - class IPluginRuntime; - - /* Parameter flags */ - #define SM_PARAM_COPYBACK (1<<0) /**< Copy an array/reference back after call */ - - /* String parameter flags (separate from parameter flags) */ - #define SM_PARAM_STRING_UTF8 (1<<0) /**< String should be UTF-8 handled */ - #define SM_PARAM_STRING_COPY (1<<1) /**< String should be copied into the plugin */ - #define SM_PARAM_STRING_BINARY (1<<2) /**< String should be handled as binary data */ - -#if defined SOURCEMOD_BUILD - /** - * @brief Pseudo-NULL reference types. - */ - enum SP_NULL_TYPE - { - SP_NULL_VECTOR = 0, /**< Float[3] reference */ - SP_NULL_STRING = 1, /**< const String[1] reference */ - }; -#endif - - /** - * @brief Represents what a function needs to implement in order to be callable. - */ - class ICallable - { - public: - /** - * @brief Pushes a cell onto the current call. - * - * @param cell Parameter value to push. - * @return Error code, if any. - */ - virtual int PushCell(cell_t cell) =0; - - /** - * @brief Pushes a cell by reference onto the current call. - * NOTE: On Execute, the pointer passed will be modified if copyback is enabled. - * NOTE: By reference parameters are cached and thus are not read until execution. - * This means you cannot push a pointer, change it, and push it again and expect - * two different values to come out. - * - * @param cell Address containing parameter value to push. - * @param flags Copy-back flags. - * @return Error code, if any. - */ - virtual int PushCellByRef(cell_t *cell, int flags=SM_PARAM_COPYBACK) =0; - - /** - * @brief Pushes a float onto the current call. - * - * @param number Parameter value to push. - * @return Error code, if any. - */ - virtual int PushFloat(float number) =0; - - /** - * @brief Pushes a float onto the current call by reference. - * NOTE: On Execute, the pointer passed will be modified if copyback is enabled. - * NOTE: By reference parameters are cached and thus are not read until execution. - * This means you cannot push a pointer, change it, and push it again and expect - * two different values to come out. - * - * @param number Parameter value to push. - & @param flags Copy-back flags. - * @return Error code, if any. - */ - virtual int PushFloatByRef(float *number, int flags=SM_PARAM_COPYBACK) =0; - - /** - * @brief Pushes an array of cells onto the current call. - * - * On Execute, the pointer passed will be modified if non-NULL and copy-back - * is enabled. - * - * By reference parameters are cached and thus are not read until execution. - * This means you cannot push a pointer, change it, and push it again and expect - * two different values to come out. - * - * @param inarray Array to copy, NULL if no initial array should be copied. - * @param cells Number of cells to allocate and optionally read from the input array. - * @param flags Whether or not changes should be copied back to the input array. - * @return Error code, if any. - */ - virtual int PushArray(cell_t *inarray, unsigned int cells, int flags=0) =0; - - /** - * @brief Pushes a string onto the current call. - * - * @param string String to push. - * @return Error code, if any. - */ - virtual int PushString(const char *string) =0; - - /** - * @brief Pushes a string or string buffer. - * - * NOTE: On Execute, the pointer passed will be modified if copy-back is enabled. - * - * @param buffer Pointer to string buffer. - * @param length Length of buffer. - * @param sz_flags String flags. In copy mode, the string will be copied - * according to the handling (ascii, utf-8, binary, etc). - * @param cp_flags Copy-back flags. - * @return Error code, if any. - */ - virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags) =0; - - /** - * @brief Cancels a function call that is being pushed but not yet executed. - * This can be used be reset for CallFunction() use. - */ - virtual void Cancel() =0; - }; - - - /** - * @brief Encapsulates a function call in a plugin. - * - * NOTE: Function calls must be atomic to one execution context. - * NOTE: This object should not be deleted. It lives for the lifetime of the plugin. - */ - class IPluginFunction : public ICallable - { - public: - /** - * @brief Executes the function, resets the pushed parameter list, and - * performs any copybacks. - * - * @param result Pointer to store return value in. - * @return Error code, if any. - */ - virtual int Execute(cell_t *result) =0; - - /** - * @brief Executes the function with the given parameter array. - * Parameters are read in forward order (i.e. index 0 is parameter #1) - * NOTE: You will get an error if you attempt to use CallFunction() with - * previously pushed parameters. - * - * @param params Array of cell parameters. - * @param num_params Number of parameters to push. - * @param result Pointer to store result of function on return. - * @return SourcePawn error code (if any). - */ - virtual int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result) =0; - - /** - * @brief Deprecated, do not use. - * - * @return GetDefaultContext() of parent runtime. - */ - virtual IPluginContext *GetParentContext() =0; - - /** - * @brief Returns whether the parent plugin is paused. - * - * @return True if runnable, false otherwise. - */ - virtual bool IsRunnable() =0; - - /** - * @brief Returns the function ID of this function. - * - * Note: This was added in API version 4. - * - * @return Function id. - */ - virtual funcid_t GetFunctionID() =0; - - /** - * @brief Executes the forward, resets the pushed parameter list, and - * performs any copybacks. - * - * Note: A function can only be executed given a runtime it was created in. - * - * @param ctx Context to execute the function in. - * @param result Pointer to store return value in. - * @return Error code, if any. - */ - virtual int Execute2(IPluginContext *ctx, cell_t *result) =0; - - /** - * @brief Executes the function with the given parameter array. - * Parameters are read in forward order (i.e. index 0 is parameter #1) - * NOTE: You will get an error if you attempt to use CallFunction() with - * previously pushed parameters. - * - * Note: A function can only be executed given a runtime it was created in. - * - * @param ctx Context to execute the function in. - * @param params Array of cell parameters. - * @param num_params Number of parameters to push. - * @param result Pointer to store result of function on return. - * @return SourcePawn error code (if any). - */ - virtual int CallFunction2(IPluginContext *ctx, - const cell_t *params, - unsigned int num_params, - cell_t *result) =0; - - /** - * @brief Returns parent plugin's runtime - * - * @return IPluginRuntime pointer. - */ - virtual IPluginRuntime *GetParentRuntime() =0; - }; - - - /** - * @brief Interface to managing a debug context at runtime. - */ - class IPluginDebugInfo - { - public: - /** - * @brief Given a code pointer, finds the file it is associated with. - * - * @param addr Code address offset. - * @param filename Pointer to store filename pointer in. - */ - virtual int LookupFile(ucell_t addr, const char **filename) =0; - - /** - * @brief Given a code pointer, finds the function it is associated with. - * - * @param addr Code address offset. - * @param name Pointer to store function name pointer in. - */ - virtual int LookupFunction(ucell_t addr, const char **name) =0; - - /** - * @brief Given a code pointer, finds the line it is associated with. - * - * @param addr Code address offset. - * @param line Pointer to store line number in. - */ - virtual int LookupLine(ucell_t addr, uint32_t *line) =0; - }; - - /** - * @brief Represents a JIT compilation or plugin loading options. - */ - class ICompilation - { - public: - /** - * @brief Sets a compilation option. - * - * @param key Option name. - * @param val Option value. - * @return True on success, false on failure. - */ - virtual bool SetOption(const char *key, const char *val) =0; - - /** - * @brief Aborts the compilation and destroys this object. - */ - virtual void Abort() =0; - }; - - /** - * @brief Interface to managing a runtime plugin. - */ - class IPluginRuntime - { - public: - /** - * @brief Virtual destructor (you may call delete). - */ - virtual ~IPluginRuntime() - { - } - - /** - * @brief Returns debug info. - * - * @return IPluginDebugInfo, or NULL if no debug info found. - */ - virtual IPluginDebugInfo *GetDebugInfo() =0; - - /** - * @brief Finds a native by name. - * - * @param name Name of native. - * @param index Optionally filled with native index number. - */ - virtual int FindNativeByName(const char *name, uint32_t *index) =0; - - /** - * @brief Gets native info by index. - * - * @param index Index number of native. - * @param native Optionally filled with pointer to native structure. - */ - virtual int GetNativeByIndex(uint32_t index, sp_native_t **native) =0; - - /** - * @brief Gets the number of natives. - * - * @return Filled with the number of natives. - */ - virtual uint32_t GetNativesNum() =0; - - /** - * @brief Finds a public function by name. - * - * @param name Name of public - * @param index Optionally filled with public index number. - */ - virtual int FindPublicByName(const char *name, uint32_t *index) =0; - - /** - * @brief Gets public function info by index. - * - * @param index Public function index number. - * @param publicptr Optionally filled with pointer to public structure. - */ - virtual int GetPublicByIndex(uint32_t index, sp_public_t **publicptr) =0; - - /** - * @brief Gets the number of public functions. - * - * @return Filled with the number of public functions. - */ - virtual uint32_t GetPublicsNum() =0; - - /** - * @brief Gets public variable info by index. - * - * @param index Public variable index number. - * @param pubvar Optionally filled with pointer to pubvar structure. - */ - virtual int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar) =0; - - /** - * @brief Finds a public variable by name. - * - * @param name Name of pubvar - * @param index Optionally filled with pubvar index number. - */ - virtual int FindPubvarByName(const char *name, uint32_t *index) =0; - - /** - * @brief Gets the addresses of a public variable. - * - * @param index Index of public variable. - * @param local_addr Address to store local address in. - * @param phys_addr Address to store physically relocated in. - */ - virtual int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr) =0; - - /** - * @brief Returns the number of public variables. - * - * @return Number of public variables. - */ - virtual uint32_t GetPubVarsNum() =0; - - /** - * @brief Returns a function by name. - * - * @param public_name Name of the function. - * @return A new IPluginFunction pointer, NULL if not found. - */ - virtual IPluginFunction *GetFunctionByName(const char *public_name) =0; - - /** - * @brief Returns a function by its id. - * - * @param func_id Function ID. - * @return A new IPluginFunction pointer, NULL if not found. - */ - virtual IPluginFunction *GetFunctionById(funcid_t func_id) =0; - - /** - * @brief Returns the default context. The default context - * should not be destroyed. - * - * @return Default context pointer. - */ - virtual IPluginContext *GetDefaultContext() =0; - - /** - * @brief Returns true if the plugin is in debug mode. - * - * @return True if in debug mode, false otherwise. - */ - virtual bool IsDebugging() =0; - - /** - * @brief Applies new compilation/runtime settings to the runtime code. - * - * The compilation object is destroyed once this function completes. - * - * @return Error code (SP_ERROR_NONE on success). - */ - virtual int ApplyCompilationOptions(ICompilation *co) =0; - - /** - * @brief Sets whether or not the plugin is paused (cannot be run). - * - * @param pause Pause state. - */ - virtual void SetPauseState(bool paused) =0; - - /** - * @brief Returns whether or not the plugin is paused (runnable). - * - * @return Pause state (true = paused, false = not). - */ - virtual bool IsPaused() =0; - - /** - * @brief Returns the estimated memory usage of this plugin. - * - * @return Memory usage, in bytes. - */ - virtual size_t GetMemUsage() =0; - - /** - * @brief Returns the MD5 hash of the plugin's P-Code. - * - * @return 16-byte buffer with MD5 hash of the plugin's P-Code. - */ - virtual unsigned char *GetCodeHash() =0; - - /** - * @brief Returns the MD5 hash of the plugin's Data. - * - * @return 16-byte buffer with MD5 hash of the plugin's Data. - */ - virtual unsigned char *GetDataHash() =0; - }; - - /** - * @brief Interface to managing a context at runtime. - */ - class IPluginContext - { - public: - /** Virtual destructor */ - virtual ~IPluginContext() { }; - public: - /** - * @brief Deprecated, does nothing. - * - * @return NULL. - */ - virtual IVirtualMachine *GetVirtualMachine() =0; - - /** - * @brief Deprecated, do not use. - * - * Returns the pointer of this object, casted to an opaque structure. - * - * @return Returns this. - */ - virtual sp_context_t *GetContext() =0; - - /** - * @brief Returns true if the plugin is in debug mode. - * - * @return True if in debug mode, false otherwise. - */ - virtual bool IsDebugging() =0; - - /** - * @brief Deprecated, does nothing. - * - * @param newpfn Unused. - * @param oldpfn Unused. - */ - virtual int SetDebugBreak(void *newpfn, void *oldpfn) =0; - - /** - * @brief Deprecated, do not use. - * - * @return NULL. - */ - virtual IPluginDebugInfo *GetDebugInfo() =0; - - /** - * @brief Allocates memory on the secondary stack of a plugin. - * Note that although called a heap, it is in fact a stack. - * - * @param cells Number of cells to allocate. - * @param local_addr Will be filled with data offset to heap. - * @param phys_addr Physical address to heap memory. - */ - virtual int HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr) =0; - - /** - * @brief Pops a heap address off the heap stack. Use this to free memory allocated with - * SP_HeapAlloc(). - * Note that in SourcePawn, the heap is in fact a bottom-up stack. Deallocations - * with this native should be performed in precisely the REVERSE order. - * - * @param local_addr Local address to free. - */ - virtual int HeapPop(cell_t local_addr) =0; - - /** - * @brief Releases a heap address using a different method than SP_HeapPop(). - * This allows you to release in any order. However, if you allocate N - * objects, release only some of them, then begin allocating again, - * you cannot go back and starting freeing the originals. - * In other words, for each chain of allocations, if you start deallocating, - * then allocating more in a chain, you must only deallocate from the current - * allocation chain. This is basically HeapPop() except on a larger scale. - * - * @param local_addr Local address to free. - */ - virtual int HeapRelease(cell_t local_addr) =0; - - /** - * @brief Deprecated, use IPluginRuntime instead. - * - * @param name Name of native. - * @param index Optionally filled with native index number. - */ - virtual int FindNativeByName(const char *name, uint32_t *index) =0; - - /** - * @brief Deprecated, use IPluginRuntime instead. - * - * @param index Index number of native. - * @param native Optionally filled with pointer to native structure. - */ - virtual int GetNativeByIndex(uint32_t index, sp_native_t **native) =0; - - /** - * @brief Deprecated, use IPluginRuntime instead. - * - * @return Filled with the number of natives. - */ - virtual uint32_t GetNativesNum() =0; - - /** - * @brief Deprecated, use IPluginRuntime instead. - * - * @param name Name of public - * @param index Optionally filled with public index number. - */ - virtual int FindPublicByName(const char *name, uint32_t *index) =0; - - /** - * @brief Deprecated, use IPluginRuntime instead. - * - * @param index Public function index number. - * @param publicptr Optionally filled with pointer to public structure. - */ - virtual int GetPublicByIndex(uint32_t index, sp_public_t **publicptr) =0; - - /** - * @brief Deprecated, use IPluginRuntime instead. - * - * @return Filled with the number of public functions. - */ - virtual uint32_t GetPublicsNum() =0; - - /** - * @brief Deprecated, use IPluginRuntime instead. - * - * @param index Public variable index number. - * @param pubvar Optionally filled with pointer to pubvar structure. - */ - virtual int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar) =0; - - /** - * @brief Deprecated, use IPluginRuntime instead. - * - * @param name Name of pubvar - * @param index Optionally filled with pubvar index number. - */ - virtual int FindPubvarByName(const char *name, uint32_t *index) =0; - - /** - * @brief Deprecated, use IPluginRuntime instead. - * - * @param index Index of public variable. - * @param local_addr Address to store local address in. - * @param phys_addr Address to store physically relocated in. - */ - virtual int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr) =0; - - /** - * @brief Deprecated, use IPluginRuntime instead. - * - * @return Number of public variables. - */ - virtual uint32_t GetPubVarsNum() =0; - - /** - * @brief Converts a plugin reference to a physical address - * - * @param local_addr Local address in plugin. - * @param phys_addr Optionally filled with relocated physical address. - */ - virtual int LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr) =0; - - /** - * @brief Converts a local address to a physical string. - * - * @param local_addr Local address in plugin. - * @param addr Destination output pointer. - */ - virtual int LocalToString(cell_t local_addr, char **addr) =0; - - /** - * @brief Converts a physical string to a local address. - * - * @param local_addr Local address in plugin. - * @param bytes Number of chars to write, including NULL terminator. - * @param source Source string to copy. - */ - virtual int StringToLocal(cell_t local_addr, size_t bytes, const char *source) =0; - - /** - * @brief Converts a physical UTF-8 string to a local address. - * This function is the same as the ANSI version, except it will copy the maximum number - * of characters possible without accidentally chopping a multi-byte character. - * - * @param local_addr Local address in plugin. - * @param maxbytes Number of bytes to write, including NULL terminator. - * @param source Source string to copy. - * @param wrtnbytes Optionally set to the number of actual bytes written. - */ - virtual int StringToLocalUTF8(cell_t local_addr, - size_t maxbytes, - const char *source, - size_t *wrtnbytes) =0; - - /** - * @brief Deprecated, does nothing. - * - * @param value Unused. - */ - virtual int PushCell(cell_t value) =0; - - /** - * @brief Deprecated, does nothing. - * - * @param local_addr Unused. - * @param phys_addr Unused. - * @param array Unused. - * @param numcells Unused. - */ - virtual int PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells) =0; - - /** - * @brief Deprecated, does nothing. - * - * @param local_addr Unused. - * @param phys_addr Unused. - * @param string Unused. - */ - virtual int PushString(cell_t *local_addr, char **phys_addr, const char *string) =0; - - /** - * @brief Deprecated, does nothing. - * - * @param array Unused. - * @param numcells Unused. - */ - virtual int PushCellsFromArray(cell_t array[], unsigned int numcells) =0; - - /** - * @brief Deprecated, does nothing. - * - * @param natives Deprecated; do not use. - * @param num Deprecated; do not use. - * @param overwrite Deprecated; do not use. - */ - virtual int BindNatives(const sp_nativeinfo_t *natives, unsigned int num, int overwrite) =0; - - /** - * @brief Deprecated, does nothing. - * - * @param native Deprecated; do not use. - */ - virtual int BindNative(const sp_nativeinfo_t *native) =0; - - /** - * @brief Deprecated, does nothing. - * - * @param native Unused. - */ - virtual int BindNativeToAny(SPVM_NATIVE_FUNC native) =0; - - /** - * @brief Deprecated, does nothing. - * - * @param code_addr Unused. - * @param result Unused. - * @return SP_ERROR_ABORTED. - */ - virtual int Execute(uint32_t code_addr, cell_t *result) =0; - - /** - * @brief Throws a error and halts any current execution. - * - * @param error The error number to set. - * @param msg Custom error message format. NULL to use default. - * @param ... Message format arguments, if any. - * @return 0 for convenience. - */ - virtual cell_t ThrowNativeErrorEx(int error, const char *msg, ...) =0; - - /** - * @brief Throws a generic native error and halts any current execution. - * - * @param msg Custom error message format. NULL to set no message. - * @param ... Message format arguments, if any. - * @return 0 for convenience. - */ - virtual cell_t ThrowNativeError(const char *msg, ...) =0; - - /** - * @brief Returns a function by name. - * - * @param public_name Name of the function. - * @return A new IPluginFunction pointer, NULL if not found. - */ - virtual IPluginFunction *GetFunctionByName(const char *public_name) =0; - - /** - * @brief Returns a function by its id. - * - * @param func_id Function ID. - * @return A new IPluginFunction pointer, NULL if not found. - */ - virtual IPluginFunction *GetFunctionById(funcid_t func_id) =0; - - /** - * @brief Returns the identity token for this context. - * - * Note: This is a compatibility shim and is the same as GetKey(1). - * - * @return Identity token. - */ - virtual SourceMod::IdentityToken_t *GetIdentity() =0; - - /** - * @brief Returns a NULL reference based on one of the available NULL - * reference types. - * - * @param type NULL reference type. - * @return cell_t address to compare to. - */ - virtual cell_t *GetNullRef(SP_NULL_TYPE type) =0; - - /** - * @brief Converts a local address to a physical string, and allows - * for NULL_STRING to be set. - * - * @param local_addr Local address in plugin. - * @param addr Destination output pointer. - */ - virtual int LocalToStringNULL(cell_t local_addr, char **addr) =0; - - /** - * @brief Deprecated; do not use. - * - * @param index Deprecated; do not use. - * @param native Deprecated; do not use. - */ - virtual int BindNativeToIndex(uint32_t index, SPVM_NATIVE_FUNC native) =0; - - /** - * @brief Returns if there is currently an execution in progress. - * - * @return True if in exec, false otherwise. - */ - virtual bool IsInExec() =0; - - /** - * @brief Returns the parent runtime of a context. - * - * @return Parent runtime. - */ - virtual IPluginRuntime *GetRuntime() =0; - - /** - * @brief Executes a function in the context. The function must be - * a member of the context's parent runtime. - * - * @param function Function. - * @param params Parameters. - * @param num_params Number of parameters in the parameter array. - * @param result Optional pointer to store the result on success. - * @return Error code. - */ - virtual int Execute2(IPluginFunction *function, - const cell_t *params, - unsigned int num_params, - cell_t *result) =0; - - /** - * @brief Returns whether a context is in an error state. - * - * This should only be used inside natives to determine whether - * a prior call failed. - */ - virtual int GetLastNativeError() =0; - - /** - * @brief Returns the local parameter stack, starting from the - * cell that contains the number of parameters passed. - * - * Local parameters are the parameters passed to the function - * from which a native was called (and thus this can only be - * called inside a native). - * - * @return Parameter stack. - */ - virtual cell_t *GetLocalParams() =0; - - /** - * @brief Sets a local "key" that can be used for fast lookup. - * - * Only the "owner" of the context should be setting this. - * - * @param key Key number (values allowed: 1 through 4). - * @param value Pointer value. - */ - virtual void SetKey(int k, void *value) =0; - - /** - * @brief Retrieves a previously set "key." - * - * @param key Key number (values allowed: 1 through 4). - * @param value Pointer to store value. - * @return True on success, false on failure. - */ - virtual bool GetKey(int k, void **value) =0; - - /** - * @brief Clears the last native error. - */ - virtual void ClearLastNativeError() =0; - }; - - - /** - * @brief Information about a position in a call stack. - */ - struct CallStackInfo - { - const char *filename; /**< NULL if not found */ - unsigned int line; /**< 0 if not found */ - const char *function; /**< NULL if not found */ - }; - - /** - * @brief Retrieves error information from a debug hook. - */ - class IContextTrace - { - public: - /** - * @brief Returns the integer error code. - * - * @return Integer error code. - */ - virtual int GetErrorCode() =0; - - /** - * @brief Returns a string describing the error. - * - * @return Error string. - */ - virtual const char *GetErrorString() =0; - - /** - * @brief Returns whether debug info is available. - * - * @return True if debug info is available, false otherwise. - */ - virtual bool DebugInfoAvailable() =0; - - /** - * @brief Returns a custom error message. - * - * @return A pointer to a custom error message, or NULL otherwise. - */ - virtual const char *GetCustomErrorString() =0; - - /** - * @brief Returns trace info for a specific point in the backtrace, if any. - * The next subsequent call to GetTraceInfo() will return the next item in the call stack. - * Calls are retrieved in descending order (i.e. the first item is at the top of the stack/call sequence). - * - * @param trace An ErrorTraceInfo buffer to store information (NULL to ignore). - * @return True if successful, false if there are no more traces. - */ - virtual bool GetTraceInfo(CallStackInfo *trace) =0; - - /** - * @brief Resets the trace to its original position (the call on the top of the stack). - */ - virtual void ResetTrace() =0; - - /** - * @brief Retrieves the name of the last native called. - * Returns NULL if there was no native that caused the error. - * - * @param index Optional pointer to store index. - * @return Native name, or NULL if none. - */ - virtual const char *GetLastNative(uint32_t *index) =0; - }; - - - /** - * @brief Provides callbacks for debug information. - */ - class IDebugListener - { - public: - /** - * @brief Invoked on a context execution error. - * - * @param ctx Context. - * @param error Object holding error information and a backtrace. - */ - virtual void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error) =0; - - /** - * @brief Called on debug spew. - * - * @param msg Message text. - * @param fmt Message formatting arguments (printf-style). - */ - virtual void OnDebugSpew(const char *msg, ...) =0; - }; - - /** - * @brief Removed. - */ - class IProfiler; - - /** - * @brief Encapsulates a profiling tool that may be attached to SourcePawn. - */ - class IProfilingTool - { - public: - /** - * @brief Return the name of the profiling tool. - * - * @return Profiling tool name. - */ - virtual const char *Name() = 0; - - /** - * @brief Description of the profiler. - * - * @return Description. - */ - virtual const char *Description() = 0; - - /** - * @brief Called to render help text. - * - * @param render Function to render one line of text. - */ - virtual void RenderHelp(void (*render)(const char *fmt, ...)) = 0; - - /** - * @brief Initiate a start command. - * - * Initiate start commands through a profiling tool, returning whether - * or not the command is supported. If starting, SourceMod will generate - * events even if it cannot signal the external profiler. - */ - virtual bool Start() = 0; - - /** - * @brief Initiate a stop command. - * - * @param render Function to render any help messages. - */ - virtual void Stop(void (*render)(const char *fmt, ...)) = 0; - - /** - * @brief Dump profiling information. - * - * Informs the profiling tool to dump any current profiling information - * it has accumulated. The format and location of the output is profiling - * tool specific. - */ - virtual void Dump() = 0; - - /** - * @brief Returns whether or not the profiler is currently profiling. - * - * @return True if active, false otherwise. - */ - virtual bool IsActive() = 0; - - /** - * @brief Returns whether the profiler is attached. - * - * @return True if attached, false otherwise. - */ - virtual bool IsAttached() = 0; - - /** - * @brief Enters the scope of an event. - * - * LeaveScope() mus be called exactly once for each call to EnterScope(). - * - * @param group A named budget group, or NULL for the default. - * @param name Event name. - */ - virtual void EnterScope(const char *group, const char *name) = 0; - - /** - * @brief Leave a profiling scope. This must be called exactly once for - * each call to EnterScope(). - */ - virtual void LeaveScope() = 0; - }; - - struct sp_plugin_s; - typedef struct sp_plugin_s sp_plugin_t; - - /** - * @brief Contains helper functions used by VMs and the host app - */ - class ISourcePawnEngine - { - public: - /** - * @brief Deprecated, do not use. - * - * @param fp Unused. - * @param err Unused. - * @return NULL. - */ - virtual sp_plugin_t *LoadFromFilePointer(FILE *fp, int *err) =0; - - /** - * @brief Deprecated, do not use, - * - * @param base Unused. - * @param plugin Unused. - * @param err Unused. - * @return NULL. - */ - virtual sp_plugin_t *LoadFromMemory(void *base, sp_plugin_t *plugin, int *err) =0; - - /** - * @brief Deprecated, do not use. - * - * @param plugin Unused. - * @return SP_ERROR_ABORTED. - */ - virtual int FreeFromMemory(sp_plugin_t *plugin) =0; - - /** - * @brief Allocates large blocks of temporary memory. - * - * @param size Size of memory to allocate. - * @return Pointer to memory, NULL if allocation failed. - */ - virtual void *BaseAlloc(size_t size) =0; - - /** - * @brief Frees memory allocated with BaseAlloc. - * - * @param memory Memory address to free. - */ - virtual void BaseFree(void *memory) =0; - - /** - * @brief Allocates executable memory. - * @deprecated Use AllocPageMemory() - * - * @param size Size of memory to allocate. - * @return Pointer to memory, NULL if allocation failed. - */ - virtual void *ExecAlloc(size_t size) =0; - - /** - * @brief Frees executable memory. - * @deprecated Use FreePageMemory() - * - * @param address Address to free. - */ - virtual void ExecFree(void *address) =0; - - /** - * @brief Sets the debug listener. This should only be called once. - * If called successively (using manual chaining), only the last function should - * attempt to call back into the same plugin. Otherwise, globally cached states - * can be accidentally overwritten. - * - * @param listener Pointer to an IDebugListener. - * @return Old IDebugListener, or NULL if none. - */ - virtual IDebugListener *SetDebugListener(IDebugListener *listener) =0; - - /** - * @brief Deprecated, do not use. - * - * @return 0. - */ - virtual unsigned int GetContextCallCount() =0; - - /** - * @brief Returns the engine API version. - * - * @return Engine API version. - */ - virtual unsigned int GetEngineAPIVersion() =0; - - /** - * @brief Allocates executable memory. - * - * @param size Size of memory to allocate. - * @return Pointer to memory, NULL if allocation failed. - */ - virtual void *AllocatePageMemory(size_t size) =0; - - /** - * @brief Sets the input memory permissions to read+write. - * - * @param ptr Memory block. - */ - virtual void SetReadWrite(void *ptr) =0; - - /** - * @brief Sets the input memory permissions to read+execute. - * - * @param ptr Memory block. - */ - virtual void SetReadExecute(void *ptr) =0; - - /** - * @brief Frees executable memory. - * - * @param ptr Address to free. - */ - virtual void FreePageMemory(void *ptr) =0; - }; - - /** - * @brief Outlines the interface a Virtual Machine (JIT) must expose - */ - class ISourcePawnEngine2 - { - public: - /** - * @brief Returns the second engine API version. - * - * @return API version. - */ - virtual unsigned int GetAPIVersion() =0; - - /** - * @brief Returns the string name of a VM implementation. - */ - virtual const char *GetEngineName() =0; - - /** - * @brief Returns a version string. - * - * @return Versioning string. - */ - virtual const char *GetVersionString() =0; - - /** - * @brief Creates a new compilation options object. - * - * @return Compilation options object. - */ - virtual ICompilation *StartCompilation() =0; - - /** - * @brief Loads a plugin from disk. - * - * If a compilation object is supplied, it is destroyed upon - * the function's return. - * - * @param co Compilation options, or NULL for defaults. - * @param file Path to the file to compile. - * @param err Error code (filled on failure); required. - * @return New runtime pointer, or NULL on failure. - */ - virtual IPluginRuntime *LoadPlugin(ICompilation *co, const char *file, int *err) =0; - - /** - * @brief Creates a fake native and binds it to a general callback function. - * - * @param callback Callback function to bind the native to. - * @param pData Private data to pass to the callback when the native is invoked. - * @return A new fake native function as a wrapper around the callback. - */ - virtual SPVM_NATIVE_FUNC CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData) =0; - - /** - * @brief Destroys a fake native function wrapper. - * - * @param func Pointer to the fake native created by CreateFakeNative. - */ - virtual void DestroyFakeNative(SPVM_NATIVE_FUNC func) =0; - - /** - * @brief Sets the debug listener. This should only be called once. - * If called successively (using manual chaining), only the last function should - * attempt to call back into the same plugin. Otherwise, globally cached states - * can be accidentally overwritten. - * - * @param listener Pointer to an IDebugListener. - * @return Old IDebugListener, or NULL if none. - */ - virtual IDebugListener *SetDebugListener(IDebugListener *listener) =0; - - /** - * @brief Deprecated. - * - * @param profiler Deprecated. - */ - virtual void SetProfiler(IProfiler *profiler) =0; - - /** - * @brief Returns the string representation of an error message. - * - * @param err Error code. - * @return Error string, or NULL if not found. - */ - virtual const char *GetErrorString(int err) =0; - - /** - * @brief Initializes the SourcePawn engine. - * - * @return True on success, false if failed. - */ - virtual bool Initialize() =0; - - /** - * @brief Shuts down the SourcePawn engine. Only needs to be called if - * Initialize() succeeded. - */ - virtual void Shutdown() =0; - - /** - * @brief Creates an empty plugin with a blob of memory. - * - * @param name Name, for debugging (NULL for anonymous). - * @param bytes Number of bytes of memory (hea+stk). - * @return New runtime, or NULL if not enough memory. - */ - virtual IPluginRuntime *CreateEmptyRuntime(const char *name, uint32_t memory) =0; - - /** - * @brief Initiates the watchdog timer with the specified timeout - * length. This cannot be called more than once. - * - * @param timeout Timeout, in ms. - * @return True on success, false on failure. - */ - virtual bool InstallWatchdogTimer(size_t timeout_ms) =0; - - /** - * @brief Sets whether the JIT is enabled or disabled. - * - * @param enabled True or false to enable or disable. - * @return True if successful, false otherwise. - */ - virtual bool SetJitEnabled(bool enabled) =0; - - /** - * @brief Returns whether the JIT is enabled. - * - * @return True if the JIT is enabled, false otherwise. - */ - virtual bool IsJitEnabled() =0; - - /** - * @brief Enables profiling. SetProfilingTool() must have been called. - * - * Note that this does not activate the profiling tool. It only enables - * notifications to the profiling tool. SourcePawn will send events to - * the profiling tool even if the tool itself is reported as inactive. - */ - virtual void EnableProfiling() = 0; - - /** - * @brief Disables profiling. - */ - virtual void DisableProfiling() = 0; - - /** - * @brief Sets the profiling tool. - * - * @param tool Profiling tool. - */ - virtual void SetProfilingTool(IProfilingTool *tool) =0; - }; -}; - -#endif //_INCLUDE_SOURCEPAWN_VM_API_H_ diff --git a/public/sourcepawn/sp_vm_base.h b/public/sourcepawn/sp_vm_base.h deleted file mode 100644 index dfcba8a8..00000000 --- a/public/sourcepawn/sp_vm_base.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * vim: set ts=4 : - * ============================================================================= - * SourcePawn - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEPAWN_VM_BASE_H_ -#define _INCLUDE_SOURCEPAWN_VM_BASE_H_ - -/** - * @file sp_vm_base.h - * @brief Contains JIT export/linkage macros. - */ - -#include - -/* :TODO: rename this to sp_vm_linkage.h */ - -#if defined WIN32 -#define EXPORT_LINK extern "C" __declspec(dllexport) -#elif defined __GNUC__ -#define EXPORT_LINK extern "C" __attribute__((visibility("default"))) -#endif - -#endif //_INCLUDE_SOURCEPAWN_VM_BASE_H_ - diff --git a/public/sourcepawn/sp_vm_types.h b/public/sourcepawn/sp_vm_types.h deleted file mode 100644 index 4dcfe4c1..00000000 --- a/public/sourcepawn/sp_vm_types.h +++ /dev/null @@ -1,225 +0,0 @@ -/** - * vim: set ts=4 sw=4 tw=99 noet: - * ============================================================================= - * SourcePawn - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEPAWN_VM_TYPES_H -#define _INCLUDE_SOURCEPAWN_VM_TYPES_H - -/** - * @file sp_vm_types.h - * @brief Contains all run-time SourcePawn structures. - */ -#include -#include - -typedef uint32_t ucell_t; /**< Unsigned 32bit integer */ -typedef int32_t cell_t; /**< Basic 32bit signed integer type for plugins */ -typedef uint32_t funcid_t; /**< Function index code */ - -#include "sp_typeutil.h" - -#define SP_MAX_EXEC_PARAMS 32 /**< Maximum number of parameters in a function */ - -#define SP_JITCONF_DEBUG "debug" /**< Configuration option for debugging. */ -#define SP_JITCONF_PROFILE "profile" /**< Configuration option for profiling. */ - -#define SP_PROF_NATIVES (1<<0) /**< Profile natives. */ -#define SP_PROF_CALLBACKS (1<<1) /**< Profile callbacks. */ -#define SP_PROF_FUNCTIONS (1<<2) /**< Profile functions. */ - -/** - * @brief Error codes for SourcePawn routines. - */ -#define SP_ERROR_NONE 0 /**< No error occurred */ -#define SP_ERROR_FILE_FORMAT 1 /**< File format unrecognized */ -#define SP_ERROR_DECOMPRESSOR 2 /**< A decompressor was not found */ -#define SP_ERROR_HEAPLOW 3 /**< Not enough space left on the heap */ -#define SP_ERROR_PARAM 4 /**< Invalid parameter or parameter type */ -#define SP_ERROR_INVALID_ADDRESS 5 /**< A memory address was not valid */ -#define SP_ERROR_NOT_FOUND 6 /**< The object in question was not found */ -#define SP_ERROR_INDEX 7 /**< Invalid index parameter */ -#define SP_ERROR_STACKLOW 8 /**< Not enough space left on the stack */ -#define SP_ERROR_NOTDEBUGGING 9 /**< Debug mode was not on or debug section not found */ -#define SP_ERROR_INVALID_INSTRUCTION 10 /**< Invalid instruction was encountered */ -#define SP_ERROR_MEMACCESS 11 /**< Invalid memory access */ -#define SP_ERROR_STACKMIN 12 /**< Stack went beyond its minimum value */ -#define SP_ERROR_HEAPMIN 13 /**< Heap went beyond its minimum value */ -#define SP_ERROR_DIVIDE_BY_ZERO 14 /**< Division by zero */ -#define SP_ERROR_ARRAY_BOUNDS 15 /**< Array index is out of bounds */ -#define SP_ERROR_INSTRUCTION_PARAM 16 /**< Instruction had an invalid parameter */ -#define SP_ERROR_STACKLEAK 17 /**< A native leaked an item on the stack */ -#define SP_ERROR_HEAPLEAK 18 /**< A native leaked an item on the heap */ -#define SP_ERROR_ARRAY_TOO_BIG 19 /**< A dynamic array is too big */ -#define SP_ERROR_TRACKER_BOUNDS 20 /**< Tracker stack is out of bounds */ -#define SP_ERROR_INVALID_NATIVE 21 /**< Native was pending or invalid */ -#define SP_ERROR_PARAMS_MAX 22 /**< Maximum number of parameters reached */ -#define SP_ERROR_NATIVE 23 /**< Error originates from a native */ -#define SP_ERROR_NOT_RUNNABLE 24 /**< Function or plugin is not runnable */ -#define SP_ERROR_ABORTED 25 /**< Function call was aborted */ -#define SP_ERROR_CODE_TOO_OLD 26 /**< Code is too old for this VM */ -#define SP_ERROR_CODE_TOO_NEW 27 /**< Code is too new for this VM */ -#define SP_ERROR_OUT_OF_MEMORY 28 /**< Out of memory */ -#define SP_ERROR_INTEGER_OVERFLOW 29 /**< Integer overflow (-INT_MIN / -1) */ -#define SP_ERROR_TIMEOUT 30 /**< Timeout */ -//Hey you! Update the string table if you add to the end of me! */ - -/********************************************** - *** The following structures are reference structures. - *** They are not essential to the API, but are used - *** to hold the back end database format of the plugin - *** binary. - **********************************************/ - -namespace SourcePawn -{ - class IPluginContext; - class IVirtualMachine; - class IProfiler; -}; - -struct sp_context_s; - -/** - * @brief Native callback prototype, passed a context and a parameter stack (0=count, 1+=args). - * A cell must be returned. - */ -typedef cell_t (*SPVM_NATIVE_FUNC)(SourcePawn::IPluginContext *, const cell_t *); - -/** - * @brief Fake native callback prototype, passed a context, parameter stack, and private data. - * A cell must be returned. - */ -typedef cell_t (*SPVM_FAKENATIVE_FUNC)(SourcePawn::IPluginContext *, const cell_t *, void *); - -/********************************************** - *** The following structures are bound to the VM/JIT. - *** Changing them will result in necessary recompilation. - **********************************************/ - -/** - * @brief Offsets and names to a public function. - */ -typedef struct sp_public_s -{ - funcid_t funcid; /**< Encoded function id */ - uint32_t code_offs; /**< Relocated code offset */ - const char *name; /**< Name of function */ -} sp_public_t; - -/** - * @brief Offsets and names to public variables. - * - * The offset is relocated and the name by default points back to the sp_plugin_infotab_t structure. - */ -typedef struct sp_pubvar_s -{ - cell_t *offs; /**< Pointer to data */ - const char *name; /**< Name */ -} sp_pubvar_t; - -#define SP_NATIVE_UNBOUND (0) /**< Native is undefined */ -#define SP_NATIVE_BOUND (1) /**< Native is bound */ - -#define SP_NTVFLAG_OPTIONAL (1<<0) /**< Native is optional */ -#define SP_NTVFLAG_EPHEMERAL (1<<1) /**< Native can be unbound */ - -/** - * @brief Native lookup table, by default names point back to the sp_plugin_infotab_t structure. - */ -typedef struct sp_native_s -{ - SPVM_NATIVE_FUNC pfn; /**< Function pointer */ - const char * name; /**< Name of function */ - uint32_t status; /**< Status flags */ - uint32_t flags; /**< Native flags */ - void * user; /**< Host-specific data */ -} sp_native_t; - -/** - * @brief Used for setting natives from modules/host apps. - */ -typedef struct sp_nativeinfo_s -{ - const char *name; /**< Name of the native */ - SPVM_NATIVE_FUNC func; /**< Address of native implementation */ -} sp_nativeinfo_t; - -/** - * @brief Run-time debug file table - */ -typedef struct sp_debug_file_s -{ - uint32_t addr; /**< Address into code */ - const char * name; /**< Name of file */ -} sp_debug_file_t; - -/** - * @brief Contains run-time debug line table. - */ -typedef struct sp_debug_line_s -{ - uint32_t addr; /**< Address into code */ - uint32_t line; /**< Line number */ -} sp_debug_line_t; - -// Occurs after an fdbg_symbol entry, for each dimension. -typedef struct sp_debug_arraydim_s -{ - int16_t tagid; /**< Tag id */ - uint32_t size; /**< Size of dimension */ -} sp_debug_arraydim_t; - -// Same as from . -typedef struct sp_debug_symbol_raw_s -{ - int32_t addr; /**< Address rel to DAT or stack frame */ - int16_t tagid; /**< Tag id */ - uint32_t codestart; /**< Start scope validity in code */ - uint32_t codeend; /**< End scope validity in code */ - uint8_t ident; /**< Variable type */ - uint8_t vclass; /**< Scope class (local vs global) */ - uint16_t dimcount; /**< Dimension count (for arrays) */ - uint32_t name; /**< Offset into debug nametable */ -} sp_debug_symbol_raw_t; - -/** - * @brief The majority of this struct is already located in the parent - * block. Thus, only the relocated portions are required. - */ -typedef struct sp_debug_symbol_s -{ - uint32_t codestart; /**< Relocated code address */ - uint32_t codeend; /**< Relocated code end address */ - const char * name; /**< Relocated name */ - sp_debug_arraydim_t *dims; /**< Relocated dimension struct, if any */ - sp_debug_symbol_raw_t *sym; /**< Pointer to original symbol */ -} sp_debug_symbol_t; - -#endif //_INCLUDE_SOURCEPAWN_VM_TYPES_H diff --git a/pushbuild.txt b/pushbuild.txt index 257cb30c..a1503e49 100644 --- a/pushbuild.txt +++ b/pushbuild.txt @@ -2,14 +2,14 @@ a billion and nanas joys of buildbot, part 2: buildbot and the very lonely square-shaped duck joys of buildbot, part 3: an accidental event proves troublesome for a psychic fish joys of buildbot, part 4: a transient mummy is perplexed by a broken wand -buildbot has horrible blugs +buildbot has horrible bloogs I am the very model of a modern major general It's no wonder the build always falls over when we call it pushing. h i D S -! +!!! joys of buildbot, part 5: a watermelon's diatribes need not be cause for spilling the queen's tea crab joys of buildbot, part 6: a merry metal matchturtle mocks mostly and mainly in Madrid. @@ -17,14 +17,14 @@ joys of buildbot, part nana: if you don't do as you are told, buildbot-san, you DS saves us from Valve again. Pants will save us from certain death. Invaders' blood marches through my veins, like GIANT RADIOACTIVE RUBBER PANTS! - THE PANTS COMMAND COMMAND ME! DO NOT IGNORE MY VEINS. +¡ THE PANTS COMMAND COMMAND ME! DO NOT IGNORE MY VEINS. ! This file sure has gotten big. sawce is rukia and loves anime, sushi, and macs ur -oh, it's so cute. she calls it a mayonegg +oh, it's so cute. she sometimes takes a little pack of mayonnaise, and she'll squirt it in her mouth all over, and then she'll take an egg and kind of... mmmmm. she calls it a mayonegg not me javaliabuf64k.. -"line 29" rhymes... kinda. <-- CONFIRMED +"line 29" rhymes.. kinda. <-- CONFIRMED The Patty Winters show this morning was about Real-Life Rambos. jksrhiojkhflhadsglk The Patty Winters Show this morning was about UFOs That Kill. @@ -65,6 +65,8 @@ glibc is bestc Buffer overflow if packet size is in a certain range, leading to server crash. Buildbot shall pay the iron price. Buildbot, I hereby challenge you to an honorable prison stabbing to the death! -Bees. +Beeeeeeeees. Beads. snakesssssssss; maple +R.I.P. Wade Boggs +Your tier1 tower is under attack.. \ No newline at end of file diff --git a/sourcepawn b/sourcepawn new file mode 160000 index 00000000..3f491d1a --- /dev/null +++ b/sourcepawn @@ -0,0 +1 @@ +Subproject commit 3f491d1a07d8459f4f80f1d992f2a090c7dd9ffb diff --git a/sourcepawn/compiler/AMBuilder b/sourcepawn/compiler/AMBuilder deleted file mode 100644 index b716d6bd..00000000 --- a/sourcepawn/compiler/AMBuilder +++ /dev/null @@ -1,118 +0,0 @@ -# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: -import os - -# Build the packing binary garbage. -scpack = SM.Program(builder, 'scpack') -if scpack.compiler.cc.behavior == 'msvc': - scpack.compiler.linkflags.remove('/SUBSYSTEM:WINDOWS') - scpack.compiler.linkflags.append('/SUBSYSTEM:CONSOLE') - scpack.compiler.cxxflags.remove('/TP') -scpack.sources = ['scpack.c'] -scpack = builder.Add(scpack) - -# Generate pack files. -packed_files = ['sc5', 'sc7'] -packed_includes = [] -for packed_file in packed_files: - # The absolute path to sc5-in.scp etc. - in_path = os.path.join(builder.currentSourcePath, '{0}-in.scp'.format(packed_file)) - - # The output file relative to the output folder, i.e. sourcepawn/compiler/sc5.scp. - out_path = os.path.join(builder.buildFolder, '{0}.scp'.format(packed_file)) - - # The absolute path to the build folder, i.e. /Users/.../sourcepawn/compiler. - build_folder = os.path.join(builder.buildPath, builder.buildFolder) - - # scpack runs in ./sourcepawn/compiler/scpack/ so we build relative paths - # from there. - scpack_argv = [ - os.path.join(builder.buildPath, scpack.binary.path), - os.path.relpath(in_path, build_folder), - os.path.relpath(os.path.join(builder.buildPath, out_path), build_folder), - ] - - _, (entry,) = builder.AddCommand( - inputs = [scpack.binary, in_path], - argv = scpack_argv, - outputs = ['{0}.scp'.format(packed_file)], - ) - packed_includes += [entry] - -binary = SM.Program(builder, 'spcomp') -compiler = binary.compiler -compiler.includes += [ - os.path.join(builder.sourcePath, 'public'), - os.path.join(builder.sourcePath, 'public', 'amtl'), - os.path.join(builder.sourcePath, 'public', 'sourcepawn'), - os.path.join(builder.sourcePath, 'sourcepawn', 'compiler'), - os.path.join(builder.sourcePath, 'sourcepawn', 'include'), - os.path.join(builder.buildPath, 'includes'), - os.path.join(builder.buildPath, builder.buildFolder), -] -compiler.sourcedeps += packed_includes - -if compiler.cc.behavior == 'gcc': - compiler.cflags += ['-Wno-format'] - compiler.c_only_flags += ['-std=c99'] - if builder.target_platform == 'linux': - compiler.postlink += ['-lm'] - compiler.postlink += ['-lstdc++'] -elif compiler.cc.behavior == 'msvc': - compiler.linkflags.remove('/SUBSYSTEM:WINDOWS') - compiler.linkflags.append('/SUBSYSTEM:CONSOLE') - compiler.cxxflags.remove('/TP') - -compiler.defines += ['HAVE_STDINT_H'] -if builder.target_platform == 'linux': - compiler.defines += [ - 'LINUX', - 'AMX_ANSIONLY', - 'ENABLE_BINRELOC', - '_GNU_SOURCE' - ] -elif builder.target_platform == 'mac': - compiler.defines += [ - 'DARWIN', - 'AMX_ANSIONLY', - 'ENABLE_BINRELOC', - 'HAVE_SAFESTR' - ] - -binary.sources += [ - 'libpawnc.cpp', - 'lstring.cpp', - 'memfile.cpp', - 'pawncc.cpp', - 'sc1.cpp', - 'sc2.cpp', - 'sc3.cpp', - 'sc4.cpp', - 'sc5.cpp', - 'sc6.cpp', - 'sc7.cpp', - 'scexpand.cpp', - 'sci18n.cpp', - 'sclist.cpp', - 'scmemfil.cpp', - 'scstate.cpp', - 'sctracker.cpp', - 'scvars.cpp', - 'smx-builder.cpp', - 'zlib/adler32.c', - 'zlib/compress.c', - 'zlib/crc32.c', - 'zlib/deflate.c', - 'zlib/gzio.c', - 'zlib/infback.c', - 'zlib/inffast.c', - 'zlib/inflate.c', - 'zlib/inftrees.c', - 'zlib/trees.c', - 'zlib/uncompr.c', - 'zlib/zutil.c', - 'sp_symhash.cpp' -] -if builder.target_platform != 'windows': - binary.sources.append('binreloc.c') - -SM.spcomp = builder.Add(binary) diff --git a/sourcepawn/compiler/Makefile b/sourcepawn/compiler/Makefile deleted file mode 100644 index 1d5c4f59..00000000 --- a/sourcepawn/compiler/Makefile +++ /dev/null @@ -1,74 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -BINARY = spcomp - -OBJECTS = binreloc.c libpawnc.c lstring.c memfile.c pawncc.c sc1.c sc2.c sc3.c sc4.c \ - sc5.c sc6.c sc7.c scexpand.c sci18n.c sclist.c scmemfil.c scstate.c sctracker.c \ - scvars.c sp_file.c sp_symhash.c -OBJECTS += zlib/adler32.c zlib/compress.c zlib/crc32.c zlib/deflate.c zlib/gzio.c \ - zlib/infback.c zlib/inffast.c zlib/inflate.c zlib/inftrees.c zlib/trees.c \ - zlib/uncompr.c zlib/zutil.c - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -fomit-frame-pointer -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -LINK = -lgcc -static-libgcc - -INCLUDE = -I. -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn - -CFLAGS += -D_GNU_SOURCE -Wall -Werror -Wno-uninitialized -Wno-unused-result -Wno-unused -Wno-switch -Wno-parentheses -Wno-format -DLINUX -DHAVE_STDINT_H -DAMX_ANSIONLY -DENABLE_BINRELOC -Dstricmp=strcasecmp -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.c - $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< - -all: - mkdir -p $(BIN_DIR)/zlib - $(MAKE) -f Makefile compiler - -compiler: $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -ldl -lm -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -default: all - -clean: - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/zlib/*.o - rm -rf $(BIN_DIR)/$(BINARY) diff --git a/sourcepawn/compiler/amx.h b/sourcepawn/compiler/amx.h deleted file mode 100644 index 7ed08dce..00000000 --- a/sourcepawn/compiler/amx.h +++ /dev/null @@ -1,634 +0,0 @@ -/* Pawn Abstract Machine (for the Pawn language) - * - * Copyright (c) ITB CompuPhase, 1997-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ - -#ifndef AMX_H_INCLUDED -#define AMX_H_INCLUDED - -#include /* for size_t */ -#include - -#if defined FREEBSD && !defined __FreeBSD__ - #define __FreeBSD__ -#endif -#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ - #include -#endif - -#if defined HAVE_STDINT_H -# include -# include -#endif - -#if defined __GNUC__ - #if !defined HAVE_STDINT_H - #define HAVE_STDINT_H - #endif -#elif !defined HAVE_STDINT_H - #if defined __LCC__ || defined __DMC__ || defined LINUX || (defined __WATCOMC__ && __WATCOMC__ >= 1200) - #if defined HAVE_INTTYPES_H - #include - #else - #include - #endif - #elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L - /* The ISO C99 defines the int16_t and int_32t types. If the compiler got - * here, these types are probably undefined. - */ - #if defined __MACH__ - #include - typedef unsigned short int uint16_t; - typedef unsigned long int uint32_t; - #elif defined __FreeBSD__ - #include - #else - typedef short int int16_t; - typedef unsigned short int uint16_t; - #if defined SN_TARGET_PS2 - typedef int int32_t; - typedef unsigned int uint32_t; - #else - typedef long int int32_t; - typedef unsigned long int uint32_t; - #endif - #if defined __WIN32__ || defined _WIN32 || defined WIN32 - typedef __int64 int64_t; - typedef unsigned __int64 uint64_t; - #define HAVE_I64 - #elif defined __GNUC__ - typedef long long int64_t; - typedef unsigned long long uint64_t; - #define HAVE_I64 - #endif - #endif - #endif - #define HAVE_STDINT_H -#endif -#if defined _LP64 || defined WIN64 || defined _WIN64 - #if !defined __64BIT__ - #define __64BIT__ - #endif -#endif - -#if HAVE_ALLOCA_H - #include -#endif -#if defined __WIN32__ || defined _WIN32 || defined WIN32 /* || defined __MSDOS__ */ - #if !defined alloca - #define alloca(n) _alloca(n) - #endif -#endif - -#if !defined arraysize - #define arraysize(array) (sizeof(array) / sizeof((array)[0])) -#endif -#if !defined assert_static - /* see "Compile-Time Assertions" by Ralf Holly, - * C/C++ Users Journal, November 2004 - */ - #define assert_static(e) \ - do { \ - enum { assert_static__ = 1/(e) }; \ - } while (0) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined PAWN_DLL - #if !defined AMX_NATIVE_CALL - #define AMX_NATIVE_CALL __stdcall - #endif - #if !defined AMXAPI - #define AMXAPI __stdcall - #endif -#endif - -/* calling convention for native functions */ -#if !defined AMX_NATIVE_CALL - #define AMX_NATIVE_CALL -#endif -/* calling convention for all interface functions and callback functions */ -#if !defined AMXAPI - #if defined STDECL - #define AMXAPI __stdcall - #elif defined CDECL - #define AMXAPI __cdecl - #elif defined GCC_HASCLASSVISIBILITY - #define AMXAPI __attribute__ ((visibility("default"))) - #else - #define AMXAPI - #endif -#endif -#if !defined AMXEXPORT - #define AMXEXPORT -#endif - -/* File format version (in CUR_FILE_VERSION) - * 0 (original version) - * 1 (opcodes JUMP.pri, SWITCH and CASETBL) - * 2 (compressed files) - * 3 (public variables) - * 4 (opcodes SWAP.pri/alt and PUSHADDR) - * 5 (tagnames table) - * 6 (reformatted header) - * 7 (name table, opcodes SYMTAG & SYSREQ.D) - * 8 (opcode STMT, renewed debug interface) - * 9 (macro opcodes) - * MIN_FILE_VERSION is the lowest file version number that the current AMX - * implementation supports. If the AMX file header gets new fields, this number - * often needs to be incremented. MAX_AMX_VERSION is the lowest AMX version that - * is needed to support the current file version. When there are new opcodes, - * this number needs to be incremented. - * The file version supported by the JIT may run behind MIN_AMX_VERSION. So - * there is an extra constant for it: MAX_FILE_VER_JIT. - */ -#define CUR_FILE_VERSION 9 /* current file version; also the current AMX version */ -#define MIN_FILE_VERSION 6 /* lowest supported file format version for the current AMX version */ -#define MIN_AMX_VERSION 9 /* minimum AMX version needed to support the current file format */ -#define MAX_FILE_VER_JIT 8 /* file version supported by the JIT */ -#define MIN_AMX_VER_JIT 8 /* AMX version supported by the JIT */ - -#if !defined PAWN_CELL_SIZE - #define PAWN_CELL_SIZE 32 /* by default, use 32-bit cells */ -#endif -#if PAWN_CELL_SIZE==16 - typedef uint16_t ucell; - typedef int16_t cell; -#elif PAWN_CELL_SIZE==32 - typedef uint32_t ucell; - typedef int32_t cell; -#elif PAWN_CELL_SIZE==64 - typedef uint64_t ucell; - typedef int64_t cell; -#else - #error Unsupported cell size (PAWN_CELL_SIZE) -#endif - -#define UNPACKEDMAX (((cell)1 << (sizeof(cell)-1)*8) - 1) -#define UNLIMITED (~1u >> 1) - -struct tagAMX; -typedef cell (AMX_NATIVE_CALL *AMX_NATIVE)(struct tagAMX *amx, cell *params); -typedef int (AMXAPI *AMX_CALLBACK)(struct tagAMX *amx, cell index, - cell *result, cell *params); -typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx); -typedef int (AMXAPI *AMX_IDLE)(struct tagAMX *amx, int AMXAPI Exec(struct tagAMX *, cell *, int)); -#if !defined _FAR - #define _FAR -#endif - -#if defined _MSC_VER - #pragma warning(disable:4103) /* disable warning message 4103 that complains - * about pragma pack in a header file */ - #pragma warning(disable:4100) /* "'%$S' : unreferenced formal parameter" */ -#endif - -/* Some compilers do not support the #pragma align, which should be fine. Some - * compilers give a warning on unknown #pragmas, which is not so fine... - */ -#if (defined SN_TARGET_PS2 || defined __GNUC__) && !defined AMX_NO_ALIGN - #define AMX_NO_ALIGN -#endif - -#if !defined AMX_NO_ALIGN - #if defined LINUX || defined __FreeBSD__ - #pragma pack(1) /* structures must be packed (byte-aligned) */ - #elif defined MACOS && defined __MWERKS__ - #pragma options align=mac68k - #else - #pragma pack(push) - #pragma pack(1) /* structures must be packed (byte-aligned) */ - #if defined __TURBOC__ - #pragma option -a- /* "pack" pragma for older Borland compilers */ - #endif - #endif -#endif - -typedef struct tagAMX_NATIVE_INFO { - const char _FAR *name; - AMX_NATIVE func; -} AMX_NATIVE_INFO; - -#define AMX_USERNUM 4 -#define sEXPMAX 19 /* maximum name length for file version <= 6 */ -#define sNAMEMAX 63 /* maximum name length of symbol name */ - -typedef struct tagAMX_FUNCSTUB { - ucell address; - char name[sEXPMAX+1]; -} AMX_FUNCSTUB; - -typedef struct tagFUNCSTUBNT { - ucell address; - uint32_t nameofs; -} AMX_FUNCSTUBNT; - -/* The AMX structure is the internal structure for many functions. Not all - * fields are valid at all times; many fields are cached in local variables. - */ -typedef struct tagAMX { - unsigned char _FAR *base; /* points to the AMX header plus the code, optionally also the data */ - unsigned char _FAR *data; /* points to separate data+stack+heap, may be NULL */ - AMX_CALLBACK callback; - AMX_DEBUG debug ; /* debug callback */ - /* for external functions a few registers must be accessible from the outside */ - cell cip ; /* instruction pointer: relative to base + amxhdr->cod */ - cell frm ; /* stack frame base: relative to base + amxhdr->dat */ - cell hea ; /* top of the heap: relative to base + amxhdr->dat */ - cell hlw ; /* bottom of the heap: relative to base + amxhdr->dat */ - cell stk ; /* stack pointer: relative to base + amxhdr->dat */ - cell stp ; /* top of the stack: relative to base + amxhdr->dat */ - int flags ; /* current status, see amx_Flags() */ - /* user data */ - long usertags[AMX_USERNUM] ; - void _FAR *userdata[AMX_USERNUM] ; - /* native functions can raise an error */ - int error ; - /* passing parameters requires a "count" field */ - int paramcount; - /* the sleep opcode needs to store the full AMX status */ - cell pri ; - cell alt ; - cell reset_stk ; - cell reset_hea ; - /* extra fields for increased performance */ - cell sysreq_d ; /* relocated address/value for the SYSREQ.D opcode */ - #if defined JIT - /* support variables for the JIT */ - int reloc_size ; /* required temporary buffer for relocations */ - long code_size ; /* estimated memory footprint of the native code */ - #endif -} AMX; - -/* The AMX_HEADER structure is both the memory format as the file format. The - * structure is used internaly. - */ -typedef struct tagAMX_HEADER { - int32_t size ; /* size of the "file" */ - uint16_t magic ; /* signature */ - char file_version ; /* file format version */ - char amx_version ; /* required version of the AMX */ - int16_t flags ; - int16_t defsize ; /* size of a definition record */ - int32_t cod ; /* initial value of COD - code block */ - int32_t dat ; /* initial value of DAT - data block */ - int32_t hea ; /* initial value of HEA - start of the heap */ - int32_t stp ; /* initial value of STP - stack top */ - int32_t cip ; /* initial value of CIP - the instruction pointer */ - int32_t publics ; /* offset to the "public functions" table */ - int32_t natives ; /* offset to the "native functions" table */ - int32_t libraries ; /* offset to the table of libraries */ - int32_t pubvars ; /* the "public variables" table */ - int32_t tags ; /* the "public tagnames" table */ - int32_t nametable ; /* name table */ -} AMX_HEADER; - -#if PAWN_CELL_SIZE==16 - #define AMX_MAGIC 0xf1e2 -#elif PAWN_CELL_SIZE==32 - #define AMX_MAGIC 0xf1e0 -#elif PAWN_CELL_SIZE==64 - #define AMX_MAGIC 0xf1e1 -#endif - -enum { - AMX_ERR_NONE, - /* reserve the first 15 error codes for exit codes of the abstract machine */ - AMX_ERR_EXIT, /* forced exit */ - AMX_ERR_ASSERT, /* assertion failed */ - AMX_ERR_STACKERR, /* stack/heap collision */ - AMX_ERR_BOUNDS, /* index out of bounds */ - AMX_ERR_MEMACCESS, /* invalid memory access */ - AMX_ERR_INVINSTR, /* invalid instruction */ - AMX_ERR_STACKLOW, /* stack underflow */ - AMX_ERR_HEAPLOW, /* heap underflow */ - AMX_ERR_CALLBACK, /* no callback, or invalid callback */ - AMX_ERR_NATIVE, /* native function failed */ - AMX_ERR_DIVIDE, /* divide by zero */ - AMX_ERR_SLEEP, /* go into sleepmode - code can be restarted */ - AMX_ERR_INVSTATE, /* invalid state for this access */ - - AMX_ERR_MEMORY = 16, /* out of memory */ - AMX_ERR_FORMAT, /* invalid file format */ - AMX_ERR_VERSION, /* file is for a newer version of the AMX */ - AMX_ERR_NOTFOUND, /* function not found */ - AMX_ERR_INDEX, /* invalid index parameter (bad entry point) */ - AMX_ERR_DEBUG, /* debugger cannot run */ - AMX_ERR_INIT, /* AMX not initialized (or doubly initialized) */ - AMX_ERR_USERDATA, /* unable to set user data field (table full) */ - AMX_ERR_INIT_JIT, /* cannot initialize the JIT */ - AMX_ERR_PARAMS, /* parameter error */ - AMX_ERR_DOMAIN, /* domain error, expression result does not fit in range */ - AMX_ERR_GENERAL, /* general error (unknown or unspecific error) */ -}; - -/* AMX_FLAG_CHAR16 0x01 no longer used */ -#define AMX_FLAG_DEBUG 0x02 /* symbolic info. available */ -#define AMX_FLAG_COMPACT 0x04 /* compact encoding */ -#define AMX_FLAG_SLEEP 0x08 /* script uses the sleep instruction (possible re-entry or power-down mode) */ -#define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no BREAK opcodes */ -#define AMX_FLAG_SYSREQN 0x800 /* script new (optimized) version of SYSREQ opcode */ -#define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */ -#define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */ -#define AMX_FLAG_BROWSE 0x4000 /* busy browsing */ -#define AMX_FLAG_RELOC 0x8000 /* jump/call addresses relocated */ - -#define AMX_EXEC_MAIN (-1) /* start at program entry point */ -#define AMX_EXEC_CONT (-2) /* continue from last address */ - -#define AMX_USERTAG(a,b,c,d) ((a) | ((b)<<8) | ((long)(c)<<16) | ((long)(d)<<24)) - -#if !defined AMX_COMPACTMARGIN - #define AMX_COMPACTMARGIN 64 -#endif - -/* for native functions that use floating point parameters, the following - * two macros are convenient for casting a "cell" into a "float" type _without_ - * changing the bit pattern - */ -#if PAWN_CELL_SIZE==32 - #define amx_ftoc(f) ( * ((cell*)&f) ) /* float to cell */ - #define amx_ctof(c) ( * ((float*)&c) ) /* cell to float */ -#elif PAWN_CELL_SIZE==64 - #define amx_ftoc(f) ( * ((cell*)&f) ) /* float to cell */ - #define amx_ctof(c) ( * ((double*)&c) ) /* cell to float */ -#else - #error Unsupported cell size -#endif - -#define amx_StrParam(amx,param,result) \ - do { \ - cell *amx_cstr_; int amx_length_; \ - amx_GetAddr((amx), (param), &amx_cstr_); \ - amx_StrLen(amx_cstr_, &amx_length_); \ - if (amx_length_ > 0 && \ - ((result) = (void*)alloca((amx_length_ + 1) * sizeof(*(result)))) != NULL) \ - amx_GetString((char*)(result), amx_cstr_, sizeof(*(result))>1, amx_length_ + 1); \ - else (result) = NULL; \ - } while (0) - -uint16_t * AMXAPI amx_Align16(uint16_t *v); -uint32_t * AMXAPI amx_Align32(uint32_t *v); -#if defined _I64_MAX || defined HAVE_I64 - uint64_t * AMXAPI amx_Align64(uint64_t *v); -#endif -int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr); -int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params); -int AMXAPI amx_Cleanup(AMX *amx); -int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data); -int AMXAPI amx_Exec(AMX *amx, cell *retval, int index); -int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index); -int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index); -int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr); -int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname); -int AMXAPI amx_Flags(AMX *amx,uint16_t *flags); -int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr); -int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname); -int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname); -int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr); -int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size); -int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id); -int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr); -int AMXAPI amx_Init(AMX *amx, void *program); -int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code); -int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap); -int AMXAPI amx_NameLength(AMX *amx, int *length); -AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func); -int AMXAPI amx_NumNatives(AMX *amx, int *number); -int AMXAPI amx_NumPublics(AMX *amx, int *number); -int AMXAPI amx_NumPubVars(AMX *amx, int *number); -int AMXAPI amx_NumTags(AMX *amx, int *number); -int AMXAPI amx_Push(AMX *amx, cell value); -int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells); -int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar); -int AMXAPI amx_RaiseError(AMX *amx, int error); -int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number); -int AMXAPI amx_Release(AMX *amx, cell amx_addr); -int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback); -int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug); -int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size); -int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr); -int AMXAPI amx_StrLen(const cell *cstring, int *length); -int AMXAPI amx_UTF8Check(const char *string, int *length); -int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value); -int AMXAPI amx_UTF8Len(const cell *cstr, int *length); -int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value); - -#if PAWN_CELL_SIZE==16 - #define amx_AlignCell(v) amx_Align16(v) -#elif PAWN_CELL_SIZE==32 - #define amx_AlignCell(v) amx_Align32(v) -#elif PAWN_CELL_SIZE==64 && (defined _I64_MAX || defined HAVE_I64) - #define amx_AlignCell(v) amx_Align64(v) -#else - #error Unsupported cell size -#endif - -#define amx_RegisterFunc(amx, name, func) \ - amx_Register((amx), amx_NativeInfo((name),(func)), 1); - -#if !defined AMX_NO_ALIGN - #if defined LINUX || defined __FreeBSD__ - #pragma pack() /* reset default packing */ - #elif defined MACOS && defined __MWERKS__ - #pragma options align=reset - #else - #pragma pack(pop) /* reset previous packing */ - #endif -#endif - -#ifdef __cplusplus -} -#endif - -typedef enum { - OP_NONE, /* invalid opcode */ - OP_LOAD_PRI, - OP_LOAD_ALT, - OP_LOAD_S_PRI, - OP_LOAD_S_ALT, - OP_LREF_PRI, - OP_LREF_ALT, - OP_LREF_S_PRI, - OP_LREF_S_ALT, - OP_LOAD_I, - OP_LODB_I, - OP_CONST_PRI, - OP_CONST_ALT, - OP_ADDR_PRI, - OP_ADDR_ALT, - OP_STOR_PRI, - OP_STOR_ALT, - OP_STOR_S_PRI, - OP_STOR_S_ALT, - OP_SREF_PRI, - OP_SREF_ALT, - OP_SREF_S_PRI, - OP_SREF_S_ALT, - OP_STOR_I, - OP_STRB_I, - OP_LIDX, - OP_LIDX_B, - OP_IDXADDR, - OP_IDXADDR_B, - OP_ALIGN_PRI, - OP_ALIGN_ALT, - OP_LCTRL, - OP_SCTRL, - OP_MOVE_PRI, - OP_MOVE_ALT, - OP_XCHG, - OP_PUSH_PRI, - OP_PUSH_ALT, - OP_PUSH_R, - OP_PUSH_C, - OP_PUSH, - OP_PUSH_S, - OP_POP_PRI, - OP_POP_ALT, - OP_STACK, - OP_HEAP, - OP_PROC, - OP_RET, - OP_RETN, - OP_CALL, - OP_CALL_PRI, - OP_JUMP, - OP_JREL, - OP_JZER, - OP_JNZ, - OP_JEQ, - OP_JNEQ, - OP_JLESS, - OP_JLEQ, - OP_JGRTR, - OP_JGEQ, - OP_JSLESS, - OP_JSLEQ, - OP_JSGRTR, - OP_JSGEQ, - OP_SHL, - OP_SHR, - OP_SSHR, - OP_SHL_C_PRI, - OP_SHL_C_ALT, - OP_SHR_C_PRI, - OP_SHR_C_ALT, - OP_SMUL, - OP_SDIV, - OP_SDIV_ALT, - OP_UMUL, - OP_UDIV, - OP_UDIV_ALT, - OP_ADD, - OP_SUB, - OP_SUB_ALT, - OP_AND, - OP_OR, - OP_XOR, - OP_NOT, - OP_NEG, - OP_INVERT, - OP_ADD_C, - OP_SMUL_C, - OP_ZERO_PRI, - OP_ZERO_ALT, - OP_ZERO, - OP_ZERO_S, - OP_SIGN_PRI, - OP_SIGN_ALT, - OP_EQ, - OP_NEQ, - OP_LESS, - OP_LEQ, - OP_GRTR, - OP_GEQ, - OP_SLESS, - OP_SLEQ, - OP_SGRTR, - OP_SGEQ, - OP_EQ_C_PRI, - OP_EQ_C_ALT, - OP_INC_PRI, - OP_INC_ALT, - OP_INC, - OP_INC_S, - OP_INC_I, - OP_DEC_PRI, - OP_DEC_ALT, - OP_DEC, - OP_DEC_S, - OP_DEC_I, - OP_MOVS, - OP_CMPS, - OP_FILL, - OP_HALT, - OP_BOUNDS, - OP_SYSREQ_PRI, - OP_SYSREQ_C, - OP_FILE, /* obsolete */ - OP_LINE, /* obsolete */ - OP_SYMBOL, /* obsolete */ - OP_SRANGE, /* obsolete */ - OP_JUMP_PRI, - OP_SWITCH, - OP_CASETBL, - OP_SWAP_PRI, - OP_SWAP_ALT, - OP_PUSH_ADR, - OP_NOP, - OP_SYSREQ_N, - OP_SYMTAG, /* obsolete */ - OP_BREAK, - OP_PUSH2_C, - OP_PUSH2, - OP_PUSH2_S, - OP_PUSH2_ADR, - OP_PUSH3_C, - OP_PUSH3, - OP_PUSH3_S, - OP_PUSH3_ADR, - OP_PUSH4_C, - OP_PUSH4, - OP_PUSH4_S, - OP_PUSH4_ADR, - OP_PUSH5_C, - OP_PUSH5, - OP_PUSH5_S, - OP_PUSH5_ADR, - OP_LOAD_BOTH, - OP_LOAD_S_BOTH, - OP_CONST, - OP_CONST_S, - /* ----- */ - OP_SYSREQ_D, - OP_SYSREQ_ND, - /* ----- */ - OP_HEAP_I, - OP_PUSH_H_C, - OP_GENARRAY, - OP_NUM_OPCODES -} OPCODE; - -#endif /* AMX_H_INCLUDED */ diff --git a/sourcepawn/compiler/amxdbg.h b/sourcepawn/compiler/amxdbg.h deleted file mode 100644 index 5726d78b..00000000 --- a/sourcepawn/compiler/amxdbg.h +++ /dev/null @@ -1,173 +0,0 @@ -/* Abstract Machine for the Pawn compiler, debugger support - * - * This file contains extra definitions that are convenient for debugger - * support. - * - * Copyright (c) ITB CompuPhase, 2005 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ - -#ifndef AMXDBG_H_INCLUDED -#define AMXDBG_H_INCLUDED - -#ifndef AMX_H_INCLUDED - #include "amx.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Some compilers do not support the #pragma align, which should be fine. Some - * compilers give a warning on unknown #pragmas, which is not so fine... - */ -#if defined SN_TARGET_PS2 || defined __GNUC__ - #define AMX_NO_ALIGN -#endif - -#if defined __GNUC__ - #define PACKED __attribute__((packed)) -#else - #define PACKED -#endif - -#if !defined AMX_NO_ALIGN - #if defined LINUX || defined __FreeBSD__ - #pragma pack(1) /* structures must be packed (byte-aligned) */ - #elif defined MACOS && defined __MWERKS__ - #pragma options align=mac68k - #else - #pragma pack(push) - #pragma pack(1) /* structures must be packed (byte-aligned) */ - #if defined __TURBOC__ - #pragma option -a- /* "pack" pragma for older Borland compilers */ - #endif - #endif -#endif - -typedef struct tagAMX_DBG_HDR { - int32_t size PACKED; /* size of the debug information chunk */ - uint16_t magic PACKED; /* signature, must be 0xf1ef */ - char file_version; /* file format version */ - char amx_version; /* required version of the AMX */ - int16_t flags PACKED; /* currently unused */ - int16_t files PACKED; /* number of entries in the "file" table */ - int32_t lines PACKED; /* number of entries in the "line" table */ - int32_t symbols PACKED; /* number of entries in the "symbol" table */ - int16_t tags PACKED; /* number of entries in the "tag" table */ - int16_t automatons PACKED; /* number of entries in the "automaton" table */ - int16_t states PACKED; /* number of entries in the "state" table */ -} PACKED AMX_DBG_HDR; -#define AMX_DBG_MAGIC 0xf1ef - -typedef struct tagAMX_DBG_FILE { - ucell address PACKED; /* address in the code segment where generated code (for this file) starts */ - char name[1]; /* ASCII string, zero-terminated */ -} PACKED AMX_DBG_FILE; - -typedef struct tagAMX_DBG_LINE { - ucell address PACKED; /* address in the code segment where generated code (for this line) starts */ - int32_t line PACKED; /* line number */ -} PACKED AMX_DBG_LINE; - -typedef struct tagAMX_DBG_SYMBOL { - ucell address PACKED; /* address in the data segment or relative to the frame */ - int16_t tag PACKED; /* tag for the symbol */ - ucell codestart PACKED; /* address in the code segment from which this symbol is valid (in scope) */ - ucell codeend PACKED; /* address in the code segment until which this symbol is valid (in scope) */ - char ident; /* kind of symbol (function/variable) */ - char vclass; /* class of symbol (global/local) */ - int16_t dim PACKED; /* number of dimensions */ - char name[1]; /* ASCII string, zero-terminated */ -} PACKED AMX_DBG_SYMBOL; - -typedef struct tagAMX_DBG_SYMDIM { - int16_t tag PACKED; /* tag for the array dimension */ - ucell size PACKED; /* size of the array dimension */ -} PACKED AMX_DBG_SYMDIM; - -typedef struct tagAMX_DBG_TAG { - int16_t tag PACKED; /* tag id */ - char name[1]; /* ASCII string, zero-terminated */ -} PACKED AMX_DBG_TAG; - -typedef struct tagAMX_DBG_MACHINE { - int16_t automaton PACKED; /* automaton id */ - ucell address PACKED; /* address of state variable */ - char name[1]; /* ASCII string, zero-terminated */ -} PACKED AMX_DBG_MACHINE; - -typedef struct tagAMX_DBG_STATE { - int16_t state PACKED; /* state id */ - int16_t automaton PACKED; /* automaton id */ - char name[1]; /* ASCII string, zero-terminated */ -} PACKED AMX_DBG_STATE; - -typedef struct tagAMX_DBG { - AMX_DBG_HDR _FAR *hdr PACKED; /* points to the AMX_DBG header */ - AMX_DBG_FILE _FAR **filetbl PACKED; - AMX_DBG_LINE _FAR *linetbl PACKED; - AMX_DBG_SYMBOL _FAR **symboltbl PACKED; - AMX_DBG_TAG _FAR **tagtbl PACKED; - AMX_DBG_MACHINE _FAR **automatontbl PACKED; - AMX_DBG_STATE _FAR **statetbl PACKED; -} PACKED AMX_DBG; - -#if !defined iVARIABLE - #define iVARIABLE 1 /* cell that has an address and that can be fetched directly (lvalue) */ - #define iREFERENCE 2 /* iVARIABLE, but must be dereferenced */ - #define iARRAY 3 - #define iREFARRAY 4 /* an array passed by reference (i.e. a pointer) */ - #define iFUNCTN 9 -#endif - - -int AMXAPI dbg_FreeInfo(AMX_DBG *amxdbg); -int AMXAPI dbg_LoadInfo(AMX_DBG *amxdbg, void *dbg_addr); - -int AMXAPI dbg_LookupFile(AMX_DBG *amxdbg, ucell address, const char **filename); -int AMXAPI dbg_LookupFunction(AMX_DBG *amxdbg, ucell address, const char **funcname); -int AMXAPI dbg_LookupLine(AMX_DBG *amxdbg, ucell address, long *line); - -int AMXAPI dbg_GetFunctionAddress(AMX_DBG *amxdbg, const char *funcname, const char *filename, ucell *address); -int AMXAPI dbg_GetLineAddress(AMX_DBG *amxdbg, long line, const char *filename, ucell *address); -int AMXAPI dbg_GetAutomatonName(AMX_DBG *amxdbg, int automaton, const char **name); -int AMXAPI dbg_GetStateName(AMX_DBG *amxdbg, int state, const char **name); -int AMXAPI dbg_GetTagName(AMX_DBG *amxdbg, int tag, const char **name); -int AMXAPI dbg_GetVariable(AMX_DBG *amxdbg, const char *symname, ucell scopeaddr, const AMX_DBG_SYMBOL **sym); -int AMXAPI dbg_GetArrayDim(AMX_DBG *amxdbg, const AMX_DBG_SYMBOL *sym, const AMX_DBG_SYMDIM **symdim); - - -#if !defined AMX_NO_ALIGN - #if defined LINUX || defined __FreeBSD__ - #pragma pack() /* reset default packing */ - #elif defined MACOS && defined __MWERKS__ - #pragma options align=reset - #else - #pragma pack(pop) /* reset previous packing */ - #endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* AMXDBG_H_INCLUDED */ - diff --git a/sourcepawn/compiler/binreloc.c b/sourcepawn/compiler/binreloc.c deleted file mode 100644 index c6dc0ae7..00000000 --- a/sourcepawn/compiler/binreloc.c +++ /dev/null @@ -1,766 +0,0 @@ -/* - * BinReloc - a library for creating relocatable executables - * Written by: Hongli Lai - * http://autopackage.org/ - * - * This source code is public domain. You can relicense this code - * under whatever license you want. - * - * See http://autopackage.org/docs/binreloc/ for - * more information and how to use this. - */ - -#ifndef __BINRELOC_C__ -#define __BINRELOC_C__ - -#ifdef ENABLE_BINRELOC - #include - #include - #include -#endif /* ENABLE_BINRELOC */ -#include -#include -#include -#include -#include "binreloc.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - - -/** @internal - * Find the canonical filename of the executable. Returns the filename - * (which must be freed) or NULL on error. If the parameter 'error' is - * not NULL, the error code will be stored there, if an error occured. - */ -static char * -_br_find_exe (BrInitError *error) -{ -#ifndef ENABLE_BINRELOC - if (error) - *error = BR_INIT_ERROR_DISABLED; - return NULL; -#else - char *path, *path2, *line, *result; - size_t buf_size; - ssize_t size; - struct stat stat_buf; - FILE *f; - - /* Read from /proc/self/exe (symlink) */ - if (sizeof (path) > SSIZE_MAX) - buf_size = SSIZE_MAX - 1; - else - buf_size = PATH_MAX - 1; - path = (char *) malloc (buf_size); - if (path == NULL) { - /* Cannot allocate memory. */ - if (error) - *error = BR_INIT_ERROR_NOMEM; - return NULL; - } - path2 = (char *) malloc (buf_size); - if (path2 == NULL) { - /* Cannot allocate memory. */ - if (error) - *error = BR_INIT_ERROR_NOMEM; - free (path); - return NULL; - } - - strncpy (path2, "/proc/self/exe", buf_size - 1); - - while (1) { - int i; - - size = readlink (path2, path, buf_size - 1); - if (size == -1) { - /* Error. */ - free (path2); - break; - } - - /* readlink() success. */ - path[size] = '\0'; - - /* Check whether the symlink's target is also a symlink. - * We want to get the final target. */ - i = stat (path, &stat_buf); - if (i == -1) { - /* Error. */ - free (path2); - break; - } - - /* stat() success. */ - if (!S_ISLNK (stat_buf.st_mode)) { - /* path is not a symlink. Done. */ - free (path2); - return path; - } - - /* path is a symlink. Continue loop and resolve this. */ - strncpy (path, path2, buf_size - 1); - } - - - /* readlink() or stat() failed; this can happen when the program is - * running in Valgrind 2.2. Read from /proc/self/maps as fallback. */ - - buf_size = PATH_MAX + 128; - line = (char *) realloc (path, buf_size); - if (line == NULL) { - /* Cannot allocate memory. */ - free (path); - if (error) - *error = BR_INIT_ERROR_NOMEM; - return NULL; - } - - f = fopen ("/proc/self/maps", "r"); - if (f == NULL) { - free (line); - if (error) - *error = BR_INIT_ERROR_OPEN_MAPS; - return NULL; - } - - /* The first entry should be the executable name. */ - result = fgets (line, (int) buf_size, f); - if (result == NULL) { - fclose (f); - free (line); - if (error) - *error = BR_INIT_ERROR_READ_MAPS; - return NULL; - } - - /* Get rid of newline character. */ - buf_size = strlen (line); - if (buf_size <= 0) { - /* Huh? An empty string? */ - fclose (f); - free (line); - if (error) - *error = BR_INIT_ERROR_INVALID_MAPS; - return NULL; - } - if (line[buf_size - 1] == 10) - line[buf_size - 1] = 0; - - /* Extract the filename; it is always an absolute path. */ - path = strchr (line, '/'); - - /* Sanity check. */ - if (strstr (line, " r-xp ") == NULL || path == NULL) { - fclose (f); - free (line); - if (error) - *error = BR_INIT_ERROR_INVALID_MAPS; - return NULL; - } - - path = strdup (path); - free (line); - fclose (f); - return path; -#endif /* ENABLE_BINRELOC */ -} - - -/** @internal - * Find the canonical filename of the executable which owns symbol. - * Returns a filename which must be freed, or NULL on error. - */ -static char * -_br_find_exe_for_symbol (const void *symbol, BrInitError *error) -{ -#ifndef ENABLE_BINRELOC - if (error) - *error = BR_INIT_ERROR_DISABLED; - return (char *) NULL; -#else - #define SIZE PATH_MAX + 100 - FILE *f; - size_t address_string_len; - char *address_string, line[SIZE], *found; - - if (symbol == NULL) - return (char *) NULL; - - f = fopen ("/proc/self/maps", "r"); - if (f == NULL) - return (char *) NULL; - - address_string_len = 4; - address_string = (char *) malloc (address_string_len); - found = (char *) NULL; - - while (!feof (f)) { - char *start_addr, *end_addr, *end_addr_end, *file; - void *start_addr_p, *end_addr_p; - size_t len; - - if (fgets (line, SIZE, f) == NULL) - break; - - /* Sanity check. */ - if (strstr (line, " r-xp ") == NULL || strchr (line, '/') == NULL) - continue; - - /* Parse line. */ - start_addr = line; - end_addr = strchr (line, '-'); - file = strchr (line, '/'); - - /* More sanity check. */ - if (!(file > end_addr && end_addr != NULL && end_addr[0] == '-')) - continue; - - end_addr[0] = '\0'; - end_addr++; - end_addr_end = strchr (end_addr, ' '); - if (end_addr_end == NULL) - continue; - - end_addr_end[0] = '\0'; - len = strlen (file); - if (len == 0) - continue; - if (file[len - 1] == '\n') - file[len - 1] = '\0'; - - /* Get rid of "(deleted)" from the filename. */ - len = strlen (file); - if (len > 10 && strcmp (file + len - 10, " (deleted)") == 0) - file[len - 10] = '\0'; - - /* I don't know whether this can happen but better safe than sorry. */ - len = strlen (start_addr); - if (len != strlen (end_addr)) - continue; - - - /* Transform the addresses into a string in the form of 0xdeadbeef, - * then transform that into a pointer. */ - if (address_string_len < len + 3) { - address_string_len = len + 3; - address_string = (char *) realloc (address_string, address_string_len); - } - - memcpy (address_string, "0x", 2); - memcpy (address_string + 2, start_addr, len); - address_string[2 + len] = '\0'; - sscanf (address_string, "%p", &start_addr_p); - - memcpy (address_string, "0x", 2); - memcpy (address_string + 2, end_addr, len); - address_string[2 + len] = '\0'; - sscanf (address_string, "%p", &end_addr_p); - - - if (symbol >= start_addr_p && symbol < end_addr_p) { - found = file; - break; - } - } - - free (address_string); - fclose (f); - - if (found == NULL) - return (char *) NULL; - else - return strdup (found); -#endif /* ENABLE_BINRELOC */ -} - - -#ifndef BINRELOC_RUNNING_DOXYGEN - #undef NULL - #define NULL ((void *) 0) /* typecasted as char* for C++ type safeness */ -#endif - -static char *exe = (char *) NULL; - - -/** Initialize the BinReloc library (for applications). - * - * This function must be called before using any other BinReloc functions. - * It attempts to locate the application's canonical filename. - * - * @note If you want to use BinReloc for a library, then you should call - * br_init_lib() instead. - * - * @param error If BinReloc failed to initialize, then the error code will - * be stored in this variable. Set to NULL if you want to - * ignore this. See #BrInitError for a list of error codes. - * - * @returns 1 on success, 0 if BinReloc failed to initialize. - */ -int -br_init (BrInitError *error) -{ - exe = _br_find_exe (error); - return exe != NULL; -} - - -/** Initialize the BinReloc library (for libraries). - * - * This function must be called before using any other BinReloc functions. - * It attempts to locate the calling library's canonical filename. - * - * @note The BinReloc source code MUST be included in your library, or this - * function won't work correctly. - * - * @param error If BinReloc failed to initialize, then the error code will - * be stored in this variable. Set to NULL if you want to - * ignore this. See #BrInitError for a list of error codes. - * - * @returns 1 on success, 0 if a filename cannot be found. - */ -int -br_init_lib (BrInitError *error) -{ - exe = _br_find_exe_for_symbol ((const void *) "", error); - return exe != NULL; -} - - -/** Find the canonical filename of the current application. - * - * @param default_exe A default filename which will be used as fallback. - * @returns A string containing the application's canonical filename, - * which must be freed when no longer necessary. If BinReloc is - * not initialized, or if br_init() failed, then a copy of - * default_exe will be returned. If default_exe is NULL, then - * NULL will be returned. - */ -char * -br_find_exe (const char *default_exe) -{ - if (exe == (char *) NULL) { - /* BinReloc is not initialized. */ - if (default_exe != (const char *) NULL) - return strdup (default_exe); - else - return (char *) NULL; - } - return strdup (exe); -} - - -/** Locate the directory in which the current application is installed. - * - * The prefix is generated by the following pseudo-code evaluation: - * \code - * dirname(exename) - * \endcode - * - * @param default_dir A default directory which will used as fallback. - * @return A string containing the directory, which must be freed when no - * longer necessary. If BinReloc is not initialized, or if the - * initialization function failed, then a copy of default_dir - * will be returned. If default_dir is NULL, then NULL will be - * returned. - */ -char * -br_find_exe_dir (const char *default_dir) -{ - if (exe == NULL) { - /* BinReloc not initialized. */ - if (default_dir != NULL) - return strdup (default_dir); - else - return NULL; - } - - return br_dirname (exe); -} - - -/** Locate the prefix in which the current application is installed. - * - * The prefix is generated by the following pseudo-code evaluation: - * \code - * dirname(dirname(exename)) - * \endcode - * - * @param default_prefix A default prefix which will used as fallback. - * @return A string containing the prefix, which must be freed when no - * longer necessary. If BinReloc is not initialized, or if - * the initialization function failed, then a copy of default_prefix - * will be returned. If default_prefix is NULL, then NULL will be returned. - */ -char * -br_find_prefix (const char *default_prefix) -{ - char *dir1, *dir2; - - if (exe == (char *) NULL) { - /* BinReloc not initialized. */ - if (default_prefix != (const char *) NULL) - return strdup (default_prefix); - else - return (char *) NULL; - } - - dir1 = br_dirname (exe); - dir2 = br_dirname (dir1); - free (dir1); - return dir2; -} - - -/** Locate the application's binary folder. - * - * The path is generated by the following pseudo-code evaluation: - * \code - * prefix + "/bin" - * \endcode - * - * @param default_bin_dir A default path which will used as fallback. - * @return A string containing the bin folder's path, which must be freed when - * no longer necessary. If BinReloc is not initialized, or if - * the initialization function failed, then a copy of default_bin_dir will - * be returned. If default_bin_dir is NULL, then NULL will be returned. - */ -char * -br_find_bin_dir (const char *default_bin_dir) -{ - char *prefix, *dir; - - prefix = br_find_prefix ((const char *) NULL); - if (prefix == (char *) NULL) { - /* BinReloc not initialized. */ - if (default_bin_dir != (const char *) NULL) - return strdup (default_bin_dir); - else - return (char *) NULL; - } - - dir = br_build_path (prefix, "bin"); - free (prefix); - return dir; -} - - -/** Locate the application's superuser binary folder. - * - * The path is generated by the following pseudo-code evaluation: - * \code - * prefix + "/sbin" - * \endcode - * - * @param default_sbin_dir A default path which will used as fallback. - * @return A string containing the sbin folder's path, which must be freed when - * no longer necessary. If BinReloc is not initialized, or if the - * initialization function failed, then a copy of default_sbin_dir will - * be returned. If default_bin_dir is NULL, then NULL will be returned. - */ -char * -br_find_sbin_dir (const char *default_sbin_dir) -{ - char *prefix, *dir; - - prefix = br_find_prefix ((const char *) NULL); - if (prefix == (char *) NULL) { - /* BinReloc not initialized. */ - if (default_sbin_dir != (const char *) NULL) - return strdup (default_sbin_dir); - else - return (char *) NULL; - } - - dir = br_build_path (prefix, "sbin"); - free (prefix); - return dir; -} - - -/** Locate the application's data folder. - * - * The path is generated by the following pseudo-code evaluation: - * \code - * prefix + "/share" - * \endcode - * - * @param default_data_dir A default path which will used as fallback. - * @return A string containing the data folder's path, which must be freed when - * no longer necessary. If BinReloc is not initialized, or if the - * initialization function failed, then a copy of default_data_dir - * will be returned. If default_data_dir is NULL, then NULL will be - * returned. - */ -char * -br_find_data_dir (const char *default_data_dir) -{ - char *prefix, *dir; - - prefix = br_find_prefix ((const char *) NULL); - if (prefix == (char *) NULL) { - /* BinReloc not initialized. */ - if (default_data_dir != (const char *) NULL) - return strdup (default_data_dir); - else - return (char *) NULL; - } - - dir = br_build_path (prefix, "share"); - free (prefix); - return dir; -} - - -/** Locate the application's localization folder. - * - * The path is generated by the following pseudo-code evaluation: - * \code - * prefix + "/share/locale" - * \endcode - * - * @param default_locale_dir A default path which will used as fallback. - * @return A string containing the localization folder's path, which must be freed when - * no longer necessary. If BinReloc is not initialized, or if the - * initialization function failed, then a copy of default_locale_dir will be returned. - * If default_locale_dir is NULL, then NULL will be returned. - */ -char * -br_find_locale_dir (const char *default_locale_dir) -{ - char *data_dir, *dir; - - data_dir = br_find_data_dir ((const char *) NULL); - if (data_dir == (char *) NULL) { - /* BinReloc not initialized. */ - if (default_locale_dir != (const char *) NULL) - return strdup (default_locale_dir); - else - return (char *) NULL; - } - - dir = br_build_path (data_dir, "locale"); - free (data_dir); - return dir; -} - - -/** Locate the application's library folder. - * - * The path is generated by the following pseudo-code evaluation: - * \code - * prefix + "/lib" - * \endcode - * - * @param default_lib_dir A default path which will used as fallback. - * @return A string containing the library folder's path, which must be freed when - * no longer necessary. If BinReloc is not initialized, or if the initialization - * function failed, then a copy of default_lib_dir will be returned. - * If default_lib_dir is NULL, then NULL will be returned. - */ -char * -br_find_lib_dir (const char *default_lib_dir) -{ - char *prefix, *dir; - - prefix = br_find_prefix ((const char *) NULL); - if (prefix == (char *) NULL) { - /* BinReloc not initialized. */ - if (default_lib_dir != (const char *) NULL) - return strdup (default_lib_dir); - else - return (char *) NULL; - } - - dir = br_build_path (prefix, "lib"); - free (prefix); - return dir; -} - - -/** Locate the application's libexec folder. - * - * The path is generated by the following pseudo-code evaluation: - * \code - * prefix + "/libexec" - * \endcode - * - * @param default_libexec_dir A default path which will used as fallback. - * @return A string containing the libexec folder's path, which must be freed when - * no longer necessary. If BinReloc is not initialized, or if the initialization - * function failed, then a copy of default_libexec_dir will be returned. - * If default_libexec_dir is NULL, then NULL will be returned. - */ -char * -br_find_libexec_dir (const char *default_libexec_dir) -{ - char *prefix, *dir; - - prefix = br_find_prefix ((const char *) NULL); - if (prefix == (char *) NULL) { - /* BinReloc not initialized. */ - if (default_libexec_dir != (const char *) NULL) - return strdup (default_libexec_dir); - else - return (char *) NULL; - } - - dir = br_build_path (prefix, "libexec"); - free (prefix); - return dir; -} - - -/** Locate the application's configuration files folder. - * - * The path is generated by the following pseudo-code evaluation: - * \code - * prefix + "/etc" - * \endcode - * - * @param default_etc_dir A default path which will used as fallback. - * @return A string containing the etc folder's path, which must be freed when - * no longer necessary. If BinReloc is not initialized, or if the initialization - * function failed, then a copy of default_etc_dir will be returned. - * If default_etc_dir is NULL, then NULL will be returned. - */ -char * -br_find_etc_dir (const char *default_etc_dir) -{ - char *prefix, *dir; - - prefix = br_find_prefix ((const char *) NULL); - if (prefix == (char *) NULL) { - /* BinReloc not initialized. */ - if (default_etc_dir != (const char *) NULL) - return strdup (default_etc_dir); - else - return (char *) NULL; - } - - dir = br_build_path (prefix, "etc"); - free (prefix); - return dir; -} - - -/*********************** - * Utility functions - ***********************/ - -/** Concatenate str1 and str2 to a newly allocated string. - * - * @param str1 A string. - * @param str2 Another string. - * @returns A newly-allocated string. This string should be freed when no longer needed. - */ -char * -br_strcat (const char *str1, const char *str2) -{ - char *result; - size_t len1, len2; - - if (str1 == NULL) - str1 = ""; - if (str2 == NULL) - str2 = ""; - - len1 = strlen (str1); - len2 = strlen (str2); - - result = (char *) malloc (len1 + len2 + 1); - memcpy (result, str1, len1); - memcpy (result + len1, str2, len2); - result[len1 + len2] = '\0'; - - return result; -} - - -char * -br_build_path (const char *dir, const char *file) -{ - char *dir2, *result; - size_t len; - int must_free = 0; - - len = strlen (dir); - if (len > 0 && dir[len - 1] != '/') { - dir2 = br_strcat (dir, "/"); - must_free = 1; - } else - dir2 = (char *) dir; - - result = br_strcat (dir2, file); - if (must_free) - free (dir2); - return result; -} - - -/* Emulates glibc's strndup() */ -static char * -br_strndup (const char *str, size_t size) -{ - char *result = (char *) NULL; - size_t len; - - if (str == (const char *) NULL) - return (char *) NULL; - - len = strlen (str); - if (len == 0) - return strdup (""); - if (size > len) - size = len; - - result = (char *) malloc (len + 1); - memcpy (result, str, size); - result[size] = '\0'; - return result; -} - - -/** Extracts the directory component of a path. - * - * Similar to g_dirname() or the dirname commandline application. - * - * Example: - * \code - * br_dirname ("/usr/local/foobar"); --> Returns: "/usr/local" - * \endcode - * - * @param path A path. - * @returns A directory name. This string should be freed when no longer needed. - */ -char * -br_dirname (const char *path) -{ - char *end, *result; - - if (path == (const char *) NULL) - return (char *) NULL; - - end = strrchr (path, '/'); - if (end == (const char *) NULL) - return strdup ("."); - - while (end > path && *end == '/') - end--; - result = br_strndup (path, end - path + 1); - if (result[0] == 0) { - free (result); - return strdup ("/"); - } else - return result; -} - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __BINRELOC_C__ */ diff --git a/sourcepawn/compiler/binreloc.h b/sourcepawn/compiler/binreloc.h deleted file mode 100644 index 4ee25c29..00000000 --- a/sourcepawn/compiler/binreloc.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * BinReloc - a library for creating relocatable executables - * Written by: Hongli Lai - * http://autopackage.org/ - * - * This source code is public domain. You can relicense this code - * under whatever license you want. - * - * See http://autopackage.org/docs/binreloc/ for - * more information and how to use this. - */ - -#ifndef __BINRELOC_H__ -#define __BINRELOC_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -/** These error codes can be returned by br_init(), br_init_lib(), gbr_init() or gbr_init_lib(). */ -typedef enum { - /** Cannot allocate memory. */ - BR_INIT_ERROR_NOMEM, - /** Unable to open /proc/self/maps; see errno for details. */ - BR_INIT_ERROR_OPEN_MAPS, - /** Unable to read from /proc/self/maps; see errno for details. */ - BR_INIT_ERROR_READ_MAPS, - /** The file format of /proc/self/maps is invalid; kernel bug? */ - BR_INIT_ERROR_INVALID_MAPS, - /** BinReloc is disabled (the ENABLE_BINRELOC macro is not defined). */ - BR_INIT_ERROR_DISABLED -} BrInitError; - - -#ifndef BINRELOC_RUNNING_DOXYGEN -/* Mangle symbol names to avoid symbol collisions with other ELF objects. */ - #define br_init SbCJ22537442193159_br_init - #define br_init_lib SbCJ22537442193159_br_init_lib - #define br_find_exe SbCJ22537442193159_br_find_exe - #define br_find_exe_dir SbCJ22537442193159_br_find_exe_dir - #define br_find_prefix SbCJ22537442193159_br_find_prefix - #define br_find_bin_dir SbCJ22537442193159_br_find_bin_dir - #define br_find_sbin_dir SbCJ22537442193159_br_find_sbin_dir - #define br_find_data_dir SbCJ22537442193159_br_find_data_dir - #define br_find_locale_dir SbCJ22537442193159_br_find_locale_dir - #define br_find_lib_dir SbCJ22537442193159_br_find_lib_dir - #define br_find_libexec_dir SbCJ22537442193159_br_find_libexec_dir - #define br_find_etc_dir SbCJ22537442193159_br_find_etc_dir - #define br_strcat SbCJ22537442193159_br_strcat - #define br_build_path SbCJ22537442193159_br_build_path - #define br_dirname SbCJ22537442193159_br_dirname - - -#endif -int br_init (BrInitError *error); -int br_init_lib (BrInitError *error); - -char *br_find_exe (const char *default_exe); -char *br_find_exe_dir (const char *default_dir); -char *br_find_prefix (const char *default_prefix); -char *br_find_bin_dir (const char *default_bin_dir); -char *br_find_sbin_dir (const char *default_sbin_dir); -char *br_find_data_dir (const char *default_data_dir); -char *br_find_locale_dir (const char *default_locale_dir); -char *br_find_lib_dir (const char *default_lib_dir); -char *br_find_libexec_dir (const char *default_libexec_dir); -char *br_find_etc_dir (const char *default_etc_dir); - -/* Utility functions */ -char *br_strcat (const char *str1, const char *str2); -char *br_build_path (const char *dir, const char *file); -char *br_dirname (const char *path); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __BINRELOC_H__ */ diff --git a/sourcepawn/compiler/getch.h b/sourcepawn/compiler/getch.h deleted file mode 100644 index 71cdd83b..00000000 --- a/sourcepawn/compiler/getch.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Extremely inefficient but portable POSIX getch(), see getch.c */ -#ifndef GETCH_H -#define GETCH_H - -#if defined __cplusplus - extern "C" { -#endif -int getch(void); -int kbhit(void); - -#if defined __cplusplus -} -#endif - -#endif /* GETCH_H */ diff --git a/sourcepawn/compiler/libpawnc.cpp b/sourcepawn/compiler/libpawnc.cpp deleted file mode 100644 index f7223fc8..00000000 --- a/sourcepawn/compiler/libpawnc.cpp +++ /dev/null @@ -1,346 +0,0 @@ -// vim: set sts=8 ts=2 sw=2 tw=99 noet: -/* LIBPAWNC.C - * - * A "glue file" for building the Pawn compiler as a DLL or shared library. - * - * Copyright (c) ITB CompuPhase, 2000-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include -#include -#include -#include -#include "sc.h" -#include "memfile.h" - -#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined DARWIN -#include -#include -#endif - -/* pc_printf() - * Called for general purpose "console" output. This function prints general - * purpose messages; errors go through pc_error(). The function is modelled - * after printf(). - */ -int pc_printf(const char *message,...) -{ - int ret; - va_list argptr; - - va_start(argptr,message); - ret=vprintf(message,argptr); - va_end(argptr); - - return ret; -} - -/* pc_error() - * Called for producing error output. - * number the error number (as documented in the manual) - * message a string describing the error with embedded %d and %s tokens - * filename the name of the file currently being parsed - * firstline the line number at which the expression started on which - * the error was found, or -1 if there is no "starting line" - * lastline the line number at which the error was detected - * argptr a pointer to the first of a series of arguments (for macro - * "va_arg") - * Return: - * If the function returns 0, the parser attempts to continue compilation. - * On a non-zero return value, the parser aborts. - */ -int pc_error(int number,const char *message,const char *filename,int firstline,int lastline,va_list argptr) -{ -static const char *prefix[3]={ "error", "fatal error", "warning" }; - - if (number!=0) { - int idx; - - if (number < FIRST_FATAL_ERROR || (number >= 200 && sc_warnings_are_errors)) - idx = 0; - else if (number < 200) - idx = 1; - else - idx = 2; - - const char *pre=prefix[idx]; - if (firstline>=0) - fprintf(stdout,"%s(%d -- %d) : %s %03d: ",filename,firstline,lastline,pre,number); - else - fprintf(stdout,"%s(%d) : %s %03d: ",filename,lastline,pre,number); - } /* if */ - vfprintf(stdout,message,argptr); - fflush(stdout); - return 0; -} - -typedef struct src_file_s { - FILE *fp; // Set if writing. - char *buffer; // IO buffer. - char *pos; // IO position. - char *end; // End of buffer. - size_t maxlength; // Maximum length of the writable buffer. -} src_file_t; - -/* pc_opensrc() - * Opens a source file (or include file) for reading. The "file" does not have - * to be a physical file, one might compile from memory. - * filename the name of the "file" to read from - * Return: - * The function must return a pointer, which is used as a "magic cookie" to - * all I/O functions. When failing to open the file for reading, the - * function must return NULL. - * Note: - * Several "source files" may be open at the same time. Specifically, one - * file can be open for reading and another for writing. - */ -void *pc_opensrc(char *filename) -{ - FILE *fp = NULL; - long length; - src_file_t *src = NULL; - -#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined DARWIN - struct stat fileInfo; - if (stat(filename, &fileInfo) != 0) { - return NULL; - } - - if (S_ISDIR(fileInfo.st_mode)) { - return NULL; - } -#endif - - if ((fp = fopen(filename, "rb")) == NULL) - return NULL; - if (fseek(fp, 0, SEEK_END) == -1) - goto err; - if ((length = ftell(fp)) == -1) - goto err; - if (fseek(fp, 0, SEEK_SET) == -1) - goto err; - - if ((src = (src_file_t *)calloc(1, sizeof(src_file_t))) == NULL) - goto err; - if ((src->buffer = (char *)calloc(length, sizeof(char))) == NULL) - goto err; - if (fread(src->buffer, length, 1, fp) != 1) - goto err; - - src->pos = src->buffer; - src->end = src->buffer + length; - fclose(fp); - return src; - -err: - pc_closesrc(src); - fclose(fp); - return NULL; -} - -/* pc_createsrc() - * Creates/overwrites a source file for writing. The "file" does not have - * to be a physical file, one might compile from memory. - * filename the name of the "file" to create - * Return: - * The function must return a pointer which is used as a "magic cookie" to - * all I/O functions. When failing to open the file for reading, the - * function must return NULL. - * Note: - * Several "source files" may be open at the same time. Specifically, one - * file can be open for reading and another for writing. - */ -void *pc_createsrc(char *filename) -{ - src_file_t *src = (src_file_t *)calloc(1, sizeof(src_file_t)); - if (!src) - return NULL; - if ((src->fp = fopen(filename, "wt")) == NULL) { - pc_closesrc(src); - return NULL; - } - - src->maxlength = 1024; - if ((src->buffer = (char *)calloc(1, src->maxlength)) == NULL) { - pc_closesrc(src); - return NULL; - } - - src->pos = src->buffer; - src->end = src->buffer + src->maxlength; - return src; -} - -/* pc_closesrc() - * Closes a source file (or include file). The "handle" parameter has the - * value that pc_opensrc() returned in an earlier call. - */ -void pc_closesrc(void *handle) -{ - src_file_t *src = (src_file_t *)handle; - if (!src) - return; - if (src->fp) { - fwrite(src->buffer, src->pos - src->buffer, 1, src->fp); - fclose(src->fp); - } - free(src->buffer); - free(src); -} - -/* pc_readsrc() - * Reads a single line from the source file (or up to a maximum number of - * characters if the line in the input file is too long). - */ -char *pc_readsrc(void *handle,unsigned char *target,int maxchars) -{ - src_file_t *src = (src_file_t *)handle; - char *outptr = (char *)target; - char *outend = outptr + maxchars; - - assert(!src->fp); - - if (src->pos == src->end) - return NULL; - - while (outptr < outend && src->pos < src->end) { - char c = *src->pos++; - *outptr++ = c; - - if (c == '\n') - break; - if (c == '\r') { - // Handle CRLF. - if (src->pos < src->end && *src->pos == '\n') { - src->pos++; - if (outptr < outend) - *outptr++ = '\n'; - } else { - // Replace with \n. - *(outptr - 1) = '\n'; - } - break; - } - } - - // Caller passes in a buffer of size >= maxchars+1. - *outptr = '\0'; - return (char *)target; -} - -/* pc_writesrc() - * Writes to to the source file. There is no automatic line ending; to end a - * line, write a "\n". - */ -int pc_writesrc(void *handle,unsigned char *source) -{ - char *str = (char *)source; - size_t len = strlen(str); - src_file_t *src = (src_file_t *)handle; - - assert(src->fp && src->maxlength); - - if (src->pos + len > src->end) { - char *newbuf; - size_t newmax = src->maxlength; - size_t newlen = (src->pos - src->buffer) + len; - while (newmax < newlen) { - // Grow by 1.5X - newmax += newmax + newmax / 2; - if (newmax < src->maxlength) - abort(); - } - - newbuf = (char *)realloc(src->buffer, newmax); - if (!newbuf) - abort(); - src->pos = newbuf + (src->pos - src->buffer); - src->end = newbuf + newmax; - src->buffer = newbuf; - src->maxlength = newmax; - } - - strcpy(src->pos, str); - src->pos += len; - return 0; -} - -void *pc_getpossrc(void *handle,void *position) -{ - src_file_t *src = (src_file_t *)handle; - - assert(!src->fp); - return (void *)(ptrdiff_t)(src->pos - src->buffer); -} - -/* pc_resetsrc() - * "position" may only hold a pointer that was previously obtained from - * pc_getpossrc() - */ -void pc_resetsrc(void *handle,void *position) -{ - src_file_t *src = (src_file_t *)handle; - ptrdiff_t pos = (ptrdiff_t)position; - - assert(!src->fp); - assert(pos >= 0 && src->buffer + pos <= src->end); - src->pos = src->buffer + pos; -} - -int pc_eofsrc(void *handle) -{ - src_file_t *src = (src_file_t *)handle; - - assert(!src->fp); - return src->pos == src->end; -} - -/* should return a pointer, which is used as a "magic cookie" to all I/O - * functions; return NULL for failure - */ -void *pc_openasm(char *filename) -{ - return mfcreate(filename); -} - -void pc_closeasm(void *handle, int deletefile) -{ - if (handle!=NULL) { - if (!deletefile) - mfdump((MEMFILE*)handle); - mfclose((MEMFILE*)handle); - } /* if */ -} - -void pc_resetasm(void *handle) -{ - mfseek((MEMFILE*)handle,0,SEEK_SET); -} - -int pc_writeasm(void *handle,const char *string) -{ - return mfputs((MEMFILE*)handle,string); -} - -char *pc_readasm(void *handle, char *string, int maxchars) -{ - return mfgets((MEMFILE*)handle,string,maxchars); -} diff --git a/sourcepawn/compiler/lstring.cpp b/sourcepawn/compiler/lstring.cpp deleted file mode 100644 index 102a956e..00000000 --- a/sourcepawn/compiler/lstring.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* Safe string copying and concatenation - * These routines are originally distributed in two separate files. I have - * copied the files verbatim in this single source file, including all comments. - * The only change is that the second set of include files is commented out - * (there is no need to include the same files twice). - */ - -#include "lstring.h" - -#if !defined HAVE_SAFESTR - -/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */ - -/* - * Copyright (c) 1998 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - #include already included through lstring.h - */ -#include /* for strlen() */ - -/* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -extern "C" size_t -strlcpy(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ -} - -/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */ - -/* - * Copyright (c) 1998 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - #include already included - #include already included -*/ - -/* - * Appends src to string dst of size siz (unlike strncat, siz is the - * full size of dst, not space left). At most siz-1 characters - * will be copied. Always NUL terminates (unless siz <= strlen(dst)). - * Returns strlen(src) + MIN(siz, strlen(initial dst)). - * If retval >= siz, truncation occurred. - */ -extern "C" size_t -strlcat(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0 && *d != '\0') - d++; - dlen = d - dst; - n = siz - dlen; - - if (n == 0) - return(dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; - n--; - } - s++; - } - *d = '\0'; - - return(dlen + (s - src)); /* count does not include NUL */ -} - -#endif /* #if !defined HAVE_SAFESTR */ diff --git a/sourcepawn/compiler/lstring.h b/sourcepawn/compiler/lstring.h deleted file mode 100644 index f8206e11..00000000 --- a/sourcepawn/compiler/lstring.h +++ /dev/null @@ -1,26 +0,0 @@ -/* prototypes for strlcpy() and strlcat() */ - -#include - -#if defined __WATCOMC__ && __WATCOMC__ >= 1240 - /* OpenWatcom introduced BSD "safe string functions" with version 1.4 */ - #define HAVE_SAFESTR -#endif - -#if !defined HAVE_SAFESTR - -#if defined(__cplusplus) -# define EXPORT extern "C" -#else -# define EXPORT -#endif - -EXPORT size_t -strlcpy(char *dst, const char *src, size_t siz); - -EXPORT size_t -strlcat(char *dst, const char *src, size_t siz); - -#undef EXPORT - -#endif diff --git a/sourcepawn/compiler/memfile.cpp b/sourcepawn/compiler/memfile.cpp deleted file mode 100644 index bc572e7f..00000000 --- a/sourcepawn/compiler/memfile.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "memfile.h" -#include -#include "osdefs.h" - -memfile_t *memfile_creat(const char *name, size_t init) -{ - memfile_t mf; - memfile_t *pmf; - - mf.size = init; - mf.base = (char *)malloc(init); - mf.usedoffs = 0; - if (!mf.base) - { - return NULL; - } - - mf.offs = 0; - mf._static = 0; - - pmf = (memfile_t *)malloc(sizeof(memfile_t)); - memcpy(pmf, &mf, sizeof(memfile_t)); - - pmf->name = strdup(name); - - return pmf; -} - -void memfile_destroy(memfile_t *mf) -{ - if (!mf) - { - return; - } - - if (!mf->_static) - { - free(mf->name); - free(mf->base); - free(mf); - } -} - -void memfile_seek(memfile_t *mf, long seek) -{ - mf->offs = seek; -} - -long memfile_tell(memfile_t *mf) -{ - return mf->offs; -} - -size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize) -{ - if (!maxsize || mf->offs >= mf->usedoffs) - { - return 0; - } - - if (mf->usedoffs - mf->offs < (long)maxsize) - { - maxsize = mf->usedoffs - mf->offs; - if (!maxsize) - { - return 0; - } - } - - memcpy(buffer, mf->base + mf->offs, maxsize); - - mf->offs += maxsize; - - return maxsize; -} - -int memfile_write(memfile_t *mf, const void *buffer, size_t size) -{ - if (mf->offs + size > mf->size) - { - size_t newsize = (mf->size + size) * 2; - if (mf->_static) - { - char *oldbase = mf->base; - mf->base = (char *)malloc(newsize); - if (!mf->base) - { - return 0; - } - memcpy(mf->base, oldbase, mf->size); - } else { - mf->base = (char *)realloc(mf->base, newsize); - if (!mf->base) - { - return 0; - } - } - mf->_static = 0; - mf->size = newsize; - } - memcpy(mf->base + mf->offs, buffer, size); - mf->offs += size; - - if (mf->offs > mf->usedoffs) - { - mf->usedoffs = mf->offs; - } - - return 1; -} - -void memfile_reset(memfile_t *mf) -{ - mf->usedoffs = 0; - mf->offs = 0; -} diff --git a/sourcepawn/compiler/memfile.h b/sourcepawn/compiler/memfile.h deleted file mode 100644 index 225e4d87..00000000 --- a/sourcepawn/compiler/memfile.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef _INCLUDE_MEMFILE_H -#define _INCLUDE_MEMFILE_H - -#include - -typedef struct memfile_s -{ - char *name; - char *base; - long offs; - long usedoffs; - size_t size; - int _static; -} memfile_t; - -/** - * Creates a new memory file - * init is the initial size in bytes - */ -memfile_t *memfile_creat(const char *name, size_t init); - -/** - * Frees the memory associated. - */ -void memfile_destroy(memfile_t *mf); - -/** - * Seeks to a given offset (always from start) - */ -void memfile_seek(memfile_t *mf, long seek); - -/** - * Writes to a memory buffer (expands as necessary). - * Returns 1 on success, 0 on failure. - */ -int memfile_write(memfile_t *mf, const void *buffer, size_t size); - -/** - * Reads a number of bytes from a memory buffer. - * Returns the number of bytes read until the end was hit. - */ -size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize); - -/** - * Returns the current position from the start. - */ -long memfile_tell(memfile_t *mf); - -/** - * Resets all the states of the memory buffer. - * (does not actually free or zero memory) - */ -void memfile_reset(memfile_t *mf); - -typedef memfile_t MEMFILE; -MEMFILE *mfcreate(const char *filename); -void mfclose(MEMFILE *mf); -int mfdump(MEMFILE *mf); -long mflength(const MEMFILE *mf); -long mfseek(MEMFILE *mf,long offset,int whence); -unsigned int mfwrite(MEMFILE *mf,const unsigned char *buffer,unsigned int size); -unsigned int mfread(MEMFILE *mf,unsigned char *buffer,unsigned int size); -char *mfgets(MEMFILE *mf,char *string,unsigned int size); -int mfputs(MEMFILE *mf,const char *string); - -#endif //_INCLUDE_MEMFILE_H diff --git a/sourcepawn/compiler/memory-buffer.h b/sourcepawn/compiler/memory-buffer.h deleted file mode 100644 index 0a92c285..00000000 --- a/sourcepawn/compiler/memory-buffer.h +++ /dev/null @@ -1,103 +0,0 @@ -// vim: set sts=2 ts=8 sw=2 tw=99 et: -// -// Copyright (C) 2012-2014 AlliedModders LLC, David Anderson -// -// This file is part of SourcePawn. -// -// SourcePawn is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free -// Software Foundation, either version 3 of the License, or (at your option) -// any later version. -// -// SourcePawn 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 -// SourcePawn. If not, see http://www.gnu.org/licenses/. -#ifndef _include_sp_memory_buffer_h_ -#define _include_sp_memory_buffer_h_ - -#include -#include -#include "smx-builder.h" - -// Interface for SmxBuilder to blit bytes. -class ISmxBuffer -{ - public: - virtual bool write(const void *bytes, size_t len) = 0; - virtual size_t pos() const = 0; -}; - -// An in-memory buffer for SmxBuilder. -class MemoryBuffer : public ISmxBuffer -{ - static const size_t kDefaultSize = 4096; - - public: - MemoryBuffer() { - buffer_ = (uint8_t *)calloc(kDefaultSize, 1); - pos_ = buffer_; - end_ = buffer_ + kDefaultSize; - } - ~MemoryBuffer() { - free(buffer_); - } - - bool write(const void *bytes, size_t len) KE_OVERRIDE { - if (pos_ + len > end_) - grow(len); - memcpy(pos_, bytes, len); - pos_ += len; - return true; - } - - size_t pos() const KE_OVERRIDE { - return pos_ - buffer_; - } - - uint8_t *bytes() const { - return buffer_; - } - size_t size() const { - return pos(); - } - void rewind(size_t newpos) { - assert(newpos < pos()); - pos_ = buffer_ + newpos; - } - - private: - void grow(size_t len) { - if (!ke::IsUintPtrAddSafe(pos(), len)) { - fprintf(stderr, "Allocation overflow!\n"); - abort(); - } - - size_t new_maxsize = end_ - buffer_; - while (pos() + len > new_maxsize) { - if (!ke::IsUintPtrMultiplySafe(new_maxsize, 2)) { - fprintf(stderr, "Allocation overflow!\n"); - abort(); - } - new_maxsize *= 2; - } - - uint8_t *newbuffer = (uint8_t *)realloc(buffer_, new_maxsize); - if (!newbuffer) { - fprintf(stderr, "Out of memory!\n"); - abort(); - } - pos_ = newbuffer + (pos_ - buffer_); - end_ = newbuffer + new_maxsize; - buffer_ = newbuffer; - } - - private: - uint8_t *buffer_; - uint8_t *pos_; - uint8_t *end_; -}; - -#endif // _include_sp_memory_buffer_h_ diff --git a/sourcepawn/compiler/msvc8/spcomp.sln b/sourcepawn/compiler/msvc8/spcomp.sln deleted file mode 100644 index 3c17272e..00000000 --- a/sourcepawn/compiler/msvc8/spcomp.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spcomp", "spcomp.vcproj", "{B4C844FF-008D-4BD5-B82F-DC06E706C64B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B4C844FF-008D-4BD5-B82F-DC06E706C64B}.Debug|Win32.ActiveCfg = Debug|Win32 - {B4C844FF-008D-4BD5-B82F-DC06E706C64B}.Debug|Win32.Build.0 = Debug|Win32 - {B4C844FF-008D-4BD5-B82F-DC06E706C64B}.Release|Win32.ActiveCfg = Release|Win32 - {B4C844FF-008D-4BD5-B82F-DC06E706C64B}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/sourcepawn/compiler/msvc8/spcomp.vcproj b/sourcepawn/compiler/msvc8/spcomp.vcproj deleted file mode 100644 index 372c316c..00000000 --- a/sourcepawn/compiler/msvc8/spcomp.vcproj +++ /dev/null @@ -1,474 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sourcepawn/compiler/msvc9/spcomp.sln b/sourcepawn/compiler/msvc9/spcomp.sln deleted file mode 100644 index b292670a..00000000 --- a/sourcepawn/compiler/msvc9/spcomp.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spcomp", "spcomp.vcproj", "{B4C844FF-008D-4BD5-B82F-DC06E706C64B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B4C844FF-008D-4BD5-B82F-DC06E706C64B}.Debug|Win32.ActiveCfg = Debug|Win32 - {B4C844FF-008D-4BD5-B82F-DC06E706C64B}.Debug|Win32.Build.0 = Debug|Win32 - {B4C844FF-008D-4BD5-B82F-DC06E706C64B}.Release|Win32.ActiveCfg = Release|Win32 - {B4C844FF-008D-4BD5-B82F-DC06E706C64B}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/sourcepawn/compiler/msvc9/spcomp.vcproj b/sourcepawn/compiler/msvc9/spcomp.vcproj deleted file mode 100644 index 3a939b2d..00000000 --- a/sourcepawn/compiler/msvc9/spcomp.vcproj +++ /dev/null @@ -1,473 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sourcepawn/compiler/osdefs.h b/sourcepawn/compiler/osdefs.h deleted file mode 100644 index 49ec2dca..00000000 --- a/sourcepawn/compiler/osdefs.h +++ /dev/null @@ -1,111 +0,0 @@ -/* __MSDOS__ set when compiling for DOS (not Windows) - * _Windows set when compiling for any version of Microsoft Windows - * __WIN32__ set when compiling for Windows95 or WindowsNT (32 bit mode) - * __32BIT__ set when compiling in 32-bit "flat" mode (DOS or Windows) - * - * Copyright 1998-2005, ITB CompuPhase, The Netherlands. - * info@compuphase.com. - */ - -#ifndef _OSDEFS_H -#define _OSDEFS_H - -/* Every compiler uses different "default" macros to indicate the mode - * it is in. Throughout the source, we use the Borland C++ macros, so - * the macros of Watcom C/C++ and Microsoft Visual C/C++ are mapped to - * those of Borland C++. - */ -#if defined(__WATCOMC__) -# if defined(__WINDOWS__) || defined(__NT__) -# define _Windows 1 -# endif -# ifdef __386__ -# define __32BIT__ 1 -# endif -# if defined(_Windows) && defined(__32BIT__) -# define __WIN32__ 1 -# endif -#elif defined(_MSC_VER) -# if defined(_WINDOWS) || defined(_WIN32) -# define _Windows 1 -# endif -# ifdef _WIN32 -# define __WIN32__ 1 -# define __32BIT__ 1 -# endif -# if _MSC_VER >= 1400 -# if !defined _CRT_SECURE_NO_DEPRECATE -# define _CRT_SECURE_NO_DEPRECATE -# endif -# define strdup _strdup -# define stricmp _stricmp -# define access _access -# define chdir _chdir -# define strdup _strdup -# define unlink _unlink -# endif -#endif - -#if defined __FreeBSD__ - #include -#elif defined __APPLE__ - #include -#elif defined LINUX - #include -#endif - -/* Linux NOW has these */ -#if !defined BIG_ENDIAN - #define BIG_ENDIAN 4321 -#endif -#if !defined LITTLE_ENDIAN - #define LITTLE_ENDIAN 1234 -#endif - -/* educated guess, BYTE_ORDER is undefined, i386 is common => little endian */ -#if !defined BYTE_ORDER - #if defined UCLINUX - #define BYTE_ORDER BIG_ENDIAN - #else - #define BYTE_ORDER LITTLE_ENDIAN - #endif -#endif - -#if defined __MSDOS__ || defined __WIN32__ || defined _Windows - #define DIRSEP_CHAR '\\' -#elif defined macintosh - #define DIRSEP_CHAR ':' -#else - #define DIRSEP_CHAR '/' /* directory separator character */ -#endif - -/* _MAX_PATH is sometimes called differently and it may be in limits.h or - * stdlib.h instead of stdio.h. - */ -#if !defined _MAX_PATH - /* not defined, perhaps stdio.h was not included */ - #if !defined PATH_MAX - #include - #endif - #if !defined _MAX_PATH && !defined PATH_MAX - /* no _MAX_PATH and no MAX_PATH, perhaps it is in limits.h */ - #include - #endif - #if !defined _MAX_PATH && !defined PATH_MAX - /* no _MAX_PATH and no MAX_PATH, perhaps it is in stdlib.h */ - #include - #endif - /* if _MAX_PATH is undefined, try common alternative names */ - #if !defined _MAX_PATH - #if defined MAX_PATH - #define _MAX_PATH MAX_PATH - #elif defined _POSIX_PATH_MAX - #define _MAX_PATH _POSIX_PATH_MAX - #else - /* everything failed, actually we have a problem here... */ - #define _MAX_PATH 1024 - #endif - #endif -#endif - -#endif /* _OSDEFS_H */ diff --git a/sourcepawn/compiler/pawn.ico b/sourcepawn/compiler/pawn.ico deleted file mode 100644 index 7a6ab60b..00000000 Binary files a/sourcepawn/compiler/pawn.ico and /dev/null differ diff --git a/sourcepawn/compiler/pawncc.cpp b/sourcepawn/compiler/pawncc.cpp deleted file mode 100644 index d98bcd75..00000000 --- a/sourcepawn/compiler/pawncc.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include -#include "memfile.h" -#include "osdefs.h" -#if defined LINUX || defined DARWIN -#include -#elif defined WIN32 -#include -#endif -#include "sc.h" - -int main(int argc, char *argv[]) -{ - return pc_compile(argc,argv); -} - -#if defined __linux__ || defined __APPLE__ -extern "C" void __cxa_pure_virtual(void) -{ -} - -void *operator new(size_t size) -{ - return malloc(size); -} - -void *operator new[](size_t size) -{ - return malloc(size); -} - -void operator delete(void *ptr) -{ - free(ptr); -} - -void operator delete[](void * ptr) -{ - free(ptr); -} -#endif diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h deleted file mode 100644 index 29ad5c4b..00000000 --- a/sourcepawn/compiler/sc.h +++ /dev/null @@ -1,1020 +0,0 @@ -// vim: set sts=2 ts=8 sw=2 tw=99 et: -/* Pawn compiler - * - * Drafted after the Small-C compiler Version 2.01, originally created - * by Ron Cain, july 1980, and enhanced by James E. Hendrix. - * - * This version comes close to a complete rewrite. - * - * Copyright R. Cain, 1980 - * Copyright J.E. Hendrix, 1982, 1983 - * Copyright ITB CompuPhase, 1997-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#ifndef SC_H_INCLUDED -#define SC_H_INCLUDED -#include -#include -#include -#if defined __BORLANDC__ && defined _Windows && !(defined __32BIT__ || defined __WIN32__) - /* setjmp() and longjmp() not well supported in 16-bit windows */ - #include - typedef int jmp_buf[9]; - #define setjmp(b) Catch(b) - #define longjmp(b,e) Throw(b,e) -#else - #include -#endif -#include "osdefs.h" -#include "amx.h" - -/* Note: the "cell" and "ucell" types are defined in AMX.H */ - -#define PUBLIC_CHAR '@' /* character that defines a function "public" */ -#define CTRL_CHAR '\\' /* default control character */ -#define sCHARBITS 8 /* size of a packed character */ - -#define MAXTAGS 16 -#define sDIMEN_MAX 4 /* maximum number of array dimensions */ -#define sLINEMAX 4095 /* input line length (in characters) */ -#define sCOMP_STACK 32 /* maximum nesting of #if .. #endif sections */ -#define sDEF_LITMAX 500 /* initial size of the literal pool, in "cells" */ -#define sDEF_AMXSTACK 4096 /* default stack size for AMX files */ -#define PREPROC_TERM '\x7f'/* termination character for preprocessor expressions (the "DEL" code) */ -#define sDEF_PREFIX "sourcemod.inc" /* default prefix filename */ -#define sARGS_MAX 32 /* number of arguments a function can have, max */ -#define sTAGS_MAX 16 /* maximum number of tags on an argument */ - -typedef union { - void *pv; /* e.g. a name */ - int i; -} stkitem; /* type of items stored on the compiler stack */ - -typedef struct s_arginfo { /* function argument info */ - char name[sNAMEMAX+1]; - char ident; /* iVARIABLE, iREFERENCE, iREFARRAY or iVARARGS */ - char usage; /* uCONST */ - int *tags; /* argument tag id. list */ - int numtags; /* number of tags in the tag list */ - int dim[sDIMEN_MAX]; - int idxtag[sDIMEN_MAX]; - int numdim; /* number of dimensions */ - unsigned char hasdefault; /* bit0: is there a default value? bit6: "tagof"; bit7: "sizeof" */ - union { - cell val; /* default value */ - struct { - char *symname; /* name of another symbol */ - short level; /* indirection level for that symbol */ - } size; /* used for "sizeof" default value */ - struct { - cell *data; /* values of default array */ - int size; /* complete length of default array */ - int arraysize; /* size to reserve on the heap */ - cell addr; /* address of the default array in the data segment */ - } array; - } defvalue; /* default value, or pointer to default array */ - int defvalue_tag; /* tag of the default value */ -} arginfo; - -/* Equate table, tagname table, library table */ -typedef struct s_constvalue { - struct s_constvalue *next; - char name[sNAMEMAX+1]; - cell value; - int index; /* index level, for constants referring to array sizes/tags - * automaton id. for states and automatons - * tag for enumeration lists */ -} constvalue; - -struct methodmap_t; - -/* Symbol table format - * - * The symbol name read from the input file is stored in "name", the - * value of "addr" is written to the output file. The address in "addr" - * depends on the class of the symbol: - * global offset into the data segment - * local offset relative to the stack frame - * label generated hexadecimal number - * function offset into code segment - */ -typedef struct s_symbol { - struct s_symbol *next; - struct s_symbol *parent; /* hierarchical types */ - char name[sNAMEMAX+1]; - uint32_t hash; /* value derived from name, for quicker searching */ - cell addr; /* address or offset (or value for constant, index for native function) */ - cell codeaddr; /* address (in the code segment) where the symbol declaration starts */ - char vclass; /* sLOCAL if "addr" refers to a local symbol */ - char ident; /* see below for possible values */ - short usage; /* see below for possible values */ - char flags; /* see below for possible values */ - int compound; /* compound level (braces nesting level) */ - int tag; /* tagname id */ - union { - int declared; /* label: how many local variables are declared */ - struct { - int index; /* array & enum: tag of array indices or the enum item */ - int field; /* enumeration fields, where a size is attached to the field */ - } tags; /* extra tags */ - constvalue *lib; /* native function: library it is part of */ - long stacksize; /* normal/public function: stack requirements */ - } x; /* 'x' for 'extra' */ - union { - arginfo *arglist; /* types of all parameters for functions */ - constvalue *enumlist;/* list of names for the "root" of an enumeration */ - struct { - cell length; /* arrays: length (size) */ - cell slength; /* if a string index, this will be set to the original size */ - short level; /* number of dimensions below this level */ - } array; - } dim; /* for 'dimension', both functions and arrays */ - constvalue *states; /* list of state function/state variable ids + addresses */ - int fnumber; /* static global variables: file number in which the declaration is visible */ - int lnumber; /* line number (in the current source file) for the declaration */ - struct s_symbol **refer; /* referrer list, functions that "use" this symbol */ - int numrefers; /* number of entries in the referrer list */ - char *documentation; /* optional documentation string */ - methodmap_t *methodmap; /* if ident == iMETHODMAP */ -} symbol; - -/* Possible entries for "ident". These are used in the "symbol", "value" - * and arginfo structures. Not every constant is valid for every use. - * In an argument list, the list is terminated with a "zero" ident; labels - * cannot be passed as function arguments, so the value 0 is overloaded. - */ -#define iLABEL 0 -#define iVARIABLE 1 /* cell that has an address and that can be fetched directly (lvalue) */ -#define iREFERENCE 2 /* iVARIABLE, but must be dereferenced */ -#define iARRAY 3 -#define iREFARRAY 4 /* an array passed by reference (i.e. a pointer) */ -#define iARRAYCELL 5 /* array element, cell that must be fetched indirectly */ -#define iARRAYCHAR 6 /* array element, character from cell from array */ -#define iEXPRESSION 7 /* expression result, has no address (rvalue) */ -#define iCONSTEXPR 8 /* constant expression (or constant symbol) */ -#define iFUNCTN 9 -#define iREFFUNC 10 -#define iVARARGS 11 /* function specified ... as argument(s) */ -#define iACCESSOR 13 /* property accessor via a methodmap_method_t */ -#define iMETHODMAP 14 /* symbol defining a methodmap */ - -/* Possible entries for "usage" - * - * This byte is used as a serie of bits, the syntax is different for - * functions and other symbols: - * - * VARIABLE - * bits: 0 (uDEFINE) the variable is defined in the source file - * 1 (uREAD) the variable is "read" (accessed) in the source file - * 2 (uWRITTEN) the variable is altered (assigned a value) - * 3 (uCONST) the variable is constant (may not be assigned to) - * 4 (uPUBLIC) the variable is public - * 6 (uSTOCK) the variable is discardable (without warning) - * - * FUNCTION - * bits: 0 (uDEFINE) the function is defined ("implemented") in the source file - * 1 (uREAD) the function is invoked in the source file - * 2 (uRETVALUE) the function returns a value (or should return a value) - * 3 (uPROTOTYPED) the function was prototyped (implicitly via a definition or explicitly) - * 4 (uPUBLIC) the function is public - * 5 (uNATIVE) the function is native - * 6 (uSTOCK) the function is discardable (without warning) - * 7 (uMISSING) the function is not implemented in this source file - * 8 (uFORWARD) the function is explicitly forwardly declared - * - * CONSTANT - * bits: 0 (uDEFINE) the symbol is defined in the source file - * 1 (uREAD) the constant is "read" (accessed) in the source file - * 2 (uWRITTEN) redundant, but may be set for constants passed by reference - * 3 (uPREDEF) the constant is pre-defined and should be kept between passes - * 5 (uENUMROOT) the constant is the "root" of an enumeration - * 6 (uENUMFIELD) the constant is a field in a named enumeration - */ -#define uDEFINE 0x001 -#define uREAD 0x002 -#define uWRITTEN 0x004 -#define uRETVALUE 0x004 /* function returns (or should return) a value */ -#define uCONST 0x008 -#define uPROTOTYPED 0x008 -#define uPREDEF 0x008 /* constant is pre-defined */ -#define uPUBLIC 0x010 -#define uNATIVE 0x020 -#define uENUMROOT 0x020 -#define uSTOCK 0x040 -#define uENUMFIELD 0x040 -#define uMISSING 0x080 -#define uFORWARD 0x100 -#define uSTRUCT 0x200 /* :TODO: make this an ident */ -/* uRETNONE is not stored in the "usage" field of a symbol. It is - * used during parsing a function, to detect a mix of "return;" and - * "return value;" in a few special cases. - */ -#define uRETNONE 0x10 - -#define flgDEPRECATED 0x01 /* symbol is deprecated (avoid use) */ - -#define uCOUNTOF 0x20 /* set in the "hasdefault" field of the arginfo struct */ -#define uTAGOF 0x40 /* set in the "hasdefault" field of the arginfo struct */ -#define uSIZEOF 0x80 /* set in the "hasdefault" field of the arginfo struct */ - -#define uMAINFUNC "main" -#define uENTRYFUNC "entry" - -#define sGLOBAL 0 /* global variable/constant class (no states) */ -#define sLOCAL 1 /* local variable/constant */ -#define sSTATIC 2 /* global life, local scope */ - -#define sSTATEVAR 3 /* criterion to find variables (sSTATEVAR implies a global variable) */ - -struct methodmap_method_s; - -typedef struct value_s { - symbol *sym; /* symbol in symbol table, NULL for (constant) expression */ - cell constval; /* value of the constant expression (if ident==iCONSTEXPR) - * also used for the size of a literal array */ - int tag; /* tag (of the expression) */ - int cmptag; /* for searching symbols: choose the one with the matching tag */ - char ident; /* iCONSTEXPR, iVARIABLE, iARRAY, iARRAYCELL, - * iEXPRESSION or iREFERENCE */ - char boolresult; /* boolean result for relational operators */ - cell *arrayidx; /* last used array indices, for checking self assignment */ - - /* when ident == iACCESSOR */ - struct methodmap_method_s *accessor; -} value; - -/* Wrapper around value + l/rvalue bit. */ -typedef struct svalue_s { - value val; - int lvalue; -} svalue; - -#define DECLFLAG_ARGUMENT 0x02 // The declaration is for an argument. -#define DECLFLAG_VARIABLE 0x04 // The declaration is for a variable. -#define DECLFLAG_ENUMROOT 0x08 // Multi-dimensional arrays should have an enumroot. -#define DECLFLAG_MAYBE_FUNCTION 0x10 // Might be a named function. -#define DECLFLAG_DYNAMIC_ARRAYS 0x20 // Dynamic arrays are allowed. -#define DECLFLAG_OLD 0x40 // Known old-style declaration. -#define DECLFLAG_FIELD 0x80 // Struct field. -#define DECLFLAG_NEW 0x100 // Known new-style declaration. -#define DECLMASK_NAMED_DECL (DECLFLAG_ARGUMENT | DECLFLAG_VARIABLE | DECLFLAG_MAYBE_FUNCTION | DECLFLAG_FIELD) - -typedef struct { - // Array information. - int numdim; - int dim[sDIMEN_MAX]; - int idxtag[sDIMEN_MAX]; - cell size; - constvalue *enumroot; - - // Type information. - int tag; // Same as tags[0]. - int tags[MAXTAGS]; // List of tags if multi-tagged. - int numtags; // Number of tags found. - int ident; // Either iREFERENCE, iARRAY, or iVARIABLE. - char usage; // Usage flags. - bool is_new; // New-style declaration. - bool has_postdims; // Dimensions, if present, were in postfix position. - - bool isCharArray() const; -} typeinfo_t; - -/* For parsing declarations. */ -typedef struct { - char name[sNAMEMAX + 1]; - typeinfo_t type; - int opertok; // Operator token, if applicable. -} declinfo_t; - -/* "while" statement queue (also used for "for" and "do - while" loops) */ -enum { - wqBRK, /* used to restore stack for "break" */ - wqCONT, /* used to restore stack for "continue" */ - wqLOOP, /* loop start label number */ - wqEXIT, /* loop exit label number (jump if false) */ - /* --- */ - wqSIZE /* "while queue" size */ -}; -#define wqTABSZ (24*wqSIZE) /* 24 nested loop statements */ - -enum { - statIDLE, /* not compiling yet */ - statFIRST, /* first pass */ - statWRITE, /* writing output */ - statSKIP, /* skipping output */ -}; - -typedef struct s_stringlist { - struct s_stringlist *next; - union { - char *line; - struct s_stringlist *tail; - }; -} stringlist; - -typedef struct s_stringpair { - struct s_stringpair *next; - char *first; - char *second; - int matchlength; - char flags; - char *documentation; -} stringpair; - -// Helper for token info. -typedef struct { - int id; - cell val; - char *str; -} token_t; - -// The method name buffer is larger since we can include our parent class's -// name, a "." to separate it, a "~" for constructors, or a ".get/.set" for -// accessors. -#define METHOD_NAMEMAX sNAMEMAX * 2 + 6 - -typedef struct { - token_t tok; - char name[METHOD_NAMEMAX + 1]; -} token_ident_t; - -/* macros for code generation */ -#define opcodes(n) ((n)*sizeof(cell)) /* opcode size */ -#define opargs(n) ((n)*sizeof(cell)) /* size of typical argument */ - -/* Tokens recognized by lex() - * Some of these constants are assigned as well to the variable "lastst" (see SC1.C) - */ -enum TokenKind { - /* value of first multi-character operator */ - tFIRST = 256, - /* multi-character operators */ - taMULT = tFIRST, /* *= */ - taDIV, /* /= */ - taMOD, /* %= */ - taADD, /* += */ - taSUB, /* -= */ - taSHL, /* <<= */ - taSHRU, /* >>>= */ - taSHR, /* >>= */ - taAND, /* &= */ - taXOR, /* ^= */ - taOR, /* |= */ - tlOR, /* || */ - tlAND, /* && */ - tlEQ, /* == */ - tlNE, /* != */ - tlLE, /* <= */ - tlGE, /* >= */ - tSHL, /* << */ - tSHRU, /* >>> */ - tSHR, /* >> */ - tINC, /* ++ */ - tDEC, /* -- */ - tELLIPS, /* ... */ - tDBLDOT, /* .. */ - tDBLCOLON, /* :: */ - /* value of last multi-character operator */ - tMIDDLE = tDBLCOLON, -/* reserved words (statements) */ - tACQUIRE, - tAS, - tASSERT, - tBEGIN, - tBREAK, - tBUILTIN, - tCATCH, - tCASE, - tCAST_TO, - tCELLSOF, - tCHAR, - tCONST, - tCONTINUE, - tDECL, - tDEFAULT, - tDEFINED, - tDELETE, - tDO, - tDOUBLE, - tELSE, - tEND, - tENUM, - tEXIT, - tEXPLICIT, - tFINALLY, - tFOR, - tFOREACH, - tFORWARD, - tFUNCENUM, - tFUNCTAG, - tFUNCTION, - tGOTO, - tIF, - tIMPLICIT, - tIMPORT, - tIN, - tINT, - tINT8, - tINT16, - tINT32, - tINT64, - tINTERFACE, - tINTN, - tLET, - tMETHODMAP, - tNAMESPACE, - tNATIVE, - tNEW, - tNULL, - tNULLABLE, - tOBJECT, - tOPERATOR, - tPACKAGE, - tPRIVATE, - tPROTECTED, - tPUBLIC, - tREADONLY, - tRETURN, - tSEALED, - tSIZEOF, - tSLEEP, - tSTATIC, - tSTOCK, - tSTRUCT, - tSWITCH, - tTAGOF, - tTHEN, - tTHIS, - tTHROW, - tTRY, - tTYPEDEF, - tTYPEOF, - tTYPESET, - tUINT8, - tUINT16, - tUINT32, - tUINT64, - tUINTN, - tUNION, - tUSING, - tVAR, - tVARIANT, - tVIEW_AS, - tVIRTUAL, - tVOID, - tVOLATILE, - tWHILE, - tWITH, - /* compiler directives */ - tpASSERT, /* #assert */ - tpDEFINE, - tpELSE, /* #else */ - tpELSEIF, /* #elseif */ - tpENDIF, - tpENDINPUT, - tpENDSCRPT, - tpERROR, - tpFILE, - tpIF, /* #if */ - tINCLUDE, - tpLINE, - tpPRAGMA, - tpTRYINCLUDE, - tpUNDEF, - tLAST = tpUNDEF, /* value of last multi-character match-able token */ - /* semicolon is a special case, because it can be optional */ - tTERM, /* semicolon or newline */ - tENDEXPR, /* forced end of expression */ - /* other recognized tokens */ - tNUMBER, /* integer number */ - tRATIONAL, /* rational number */ - tSYMBOL, - tLABEL, - tSTRING, - tPENDING_STRING, /* string, but not yet dequeued */ - tEXPR, /* for assigment to "lastst" only (see SC1.C) */ - tENDLESS, /* endless loop, for assigment to "lastst" only */ - tEMPTYBLOCK, /* empty blocks for AM bug 4825 */ - tEOL, /* newline, only returned by peek_new_line() */ - tNEWDECL, /* for declloc() */ - tLAST_TOKEN_ID -}; - -/* (reversed) evaluation of staging buffer */ -#define sSTARTREORDER 0x01 -#define sENDREORDER 0x02 -#define sEXPRSTART 0x80 /* top bit set, rest is free */ -#define sMAXARGS 127 /* relates to the bit pattern of sEXPRSTART */ - -#define sDOCSEP 0x01 /* to separate documentation comments between functions */ - -/* codes for ffabort() */ -#define xEXIT 1 /* exit code in PRI */ -#define xASSERTION 2 /* abort caused by failing assertion */ -#define xSTACKERROR 3 /* stack/heap overflow */ -#define xBOUNDSERROR 4 /* array index out of bounds */ -#define xMEMACCESS 5 /* data access error */ -#define xINVINSTR 6 /* invalid instruction */ -#define xSTACKUNDERFLOW 7 /* stack underflow */ -#define xHEAPUNDERFLOW 8 /* heap underflow */ -#define xCALLBACKERR 9 /* no, or invalid, callback */ -#define xSLEEP 12 /* sleep, exit code in PRI, tag in ALT */ - -/* Miscellaneous */ -#if !defined TRUE - #define FALSE 0 - #define TRUE 1 -#endif -#define sIN_CSEG 1 /* if parsing CODE */ -#define sIN_DSEG 2 /* if parsing DATA */ -#define sCHKBOUNDS 1 /* bit position in "debug" variable: check bounds */ -#define sSYMBOLIC 2 /* bit position in "debug" variable: symbolic info */ -#define sRESET 0 /* reset error flag */ -#define sFORCESET 1 /* force error flag on */ -#define sEXPRMARK 2 /* mark start of expression */ -#define sEXPRRELEASE 3 /* mark end of expression */ -#define sSETPOS 4 /* set line number for the error */ - -enum { - sOPTIMIZE_NONE, /* no optimization */ - sOPTIMIZE_NOMACRO, /* no macro instructions */ - sOPTIMIZE_DEFAULT, /* full optimization */ - /* ----- */ - sOPTIMIZE_NUMBER -}; - -typedef enum s_regid { - sPRI, /* indicates the primary register */ - sALT, /* indicates the secundary register */ -} regid; - -typedef enum s_optmark { - sEXPR, /* end of expression (for expressions that form a statement) */ - sPARM, /* end of parameter (in a function parameter list) */ - sLDECL, /* start of local declaration (variable) */ -} optmark; - -#define suSLEEP_INSTR 0x01 /* the "sleep" instruction was used */ - -#define FIXEDTAG 0x40000000Lu -#define FUNCTAG 0x20000000Lu -#define OBJECTTAG 0x10000000Lu -#define ENUMTAG 0x08000000Lu -#define METHODMAPTAG 0x04000000Lu -#define STRUCTTAG 0x02000000Lu -#define TAGTYPEMASK (FUNCTAG | OBJECTTAG | ENUMTAG | METHODMAPTAG | STRUCTTAG) -#define TAGFLAGMASK (FIXEDTAG | TAGTYPEMASK) -#define TAGID(tag) ((tag) & ~(TAGFLAGMASK)) -#define CELL_MAX (((ucell)1 << (sizeof(cell)*8-1)) - 1) - - -/* - * Functions you call from the "driver" program - */ -int pc_compile(int argc, char **argv); -int pc_addconstant(const char *name,cell value,int tag); -int pc_addtag(const char *name); -int pc_addtag_flags(const char *name, int flags); -int pc_findtag(const char *name); -constvalue *pc_tagptr(const char *name); -int pc_enablewarning(int number,int enable); -const char *pc_tagname(int tag); -int parse_decl(declinfo_t *decl, int flags); -const char *type_to_name(int tag); -bool parse_new_typename(const token_t *tok, int *tagp); - -/* - * Functions called from the compiler (to be implemented by you) - */ - -/* general console output */ -int pc_printf(const char *message,...); - -/* error report function */ -int pc_error(int number,const char *message,const char *filename,int firstline,int lastline,va_list argptr); - -/* input from source file */ -void *pc_opensrc(char *filename); /* reading only */ -void *pc_createsrc(char *filename); -void pc_closesrc(void *handle); /* never delete */ -char *pc_readsrc(void *handle,unsigned char *target,int maxchars); -int pc_writesrc(void *handle,unsigned char *source); -void *pc_getpossrc(void *handle,void *position); /* mark the current position */ -void pc_resetsrc(void *handle,void *position); /* reset to a position marked earlier */ -int pc_eofsrc(void *handle); - -/* output to intermediate (.ASM) file */ -void *pc_openasm(char *filename); /* read/write */ -void pc_closeasm(void *handle,int deletefile); -void pc_resetasm(void *handle); -int pc_writeasm(void *handle,const char *str); -char *pc_readasm(void *handle,char *target,int maxchars); - -void sp_fdbg_ntv_start(int num_natives); -void sp_fdbg_ntv_hook(int index, symbol *sym); - -/* function prototypes in SC1.C */ -void set_extension(char *filename,const char *extension,int force); -symbol *fetchfunc(char *name); -char *operator_symname(char *symname,const char *opername,int tag1,int tag2,int numtags,int resulttag); -char *funcdisplayname(char *dest,char *funcname); -int exprconst(cell *val,int *tag,symbol **symptr); -constvalue *append_constval(constvalue *table,const char *name,cell val,int index); -constvalue *find_constval(constvalue *table,char *name,int index); -void delete_consttable(constvalue *table); -symbol *add_constant(const char *name,cell val,int vclass,int tag); -void sc_attachdocumentation(symbol *sym); -constvalue *find_tag_byval(int tag); -int get_actual_compound(symbol *sym); - -/* function prototypes in SC2.C */ -#define PUSHSTK_P(v) { stkitem s_; s_.pv=(v); pushstk(s_); } -#define PUSHSTK_I(v) { stkitem s_; s_.i=(v); pushstk(s_); } -#define POPSTK_P() (popstk().pv) -#define POPSTK_I() (popstk().i) -void pushstk(stkitem val); -stkitem popstk(void); -void clearstk(void); -int plungequalifiedfile(char *name); /* explicit path included */ -int plungefile(char *name,int try_currentpath,int try_includepaths); /* search through "include" paths */ -void preprocess(void); -void lexinit(void); -int lex(cell *lexvalue,char **lexsym); -int lextok(token_t *tok); -int lexpeek(int id); -void lexpush(void); -void lexclr(int clreol); -int matchtoken(int token); -int tokeninfo(cell *val,char **str); -int needtoken(int token); -int matchtoken2(int id, token_t *tok); -int expecttoken(int id, token_t *tok); -int matchsymbol(token_ident_t *ident); -int needsymbol(token_ident_t *ident); -int peek_same_line(); -int require_newline(int allow_semi); -void litadd(cell value); -void litinsert(cell value,int pos); -int alphanum(char c); -int ishex(char c); -void delete_symbol(symbol *root,symbol *sym); -void delete_symbols(symbol *root,int level,int del_labels,int delete_functions); -int refer_symbol(symbol *entry,symbol *bywhom); -void markusage(symbol *sym,int usage); -symbol *findglb(const char *name,int filter); -symbol *findloc(const char *name); -symbol *findconst(const char *name,int *matchtag); -symbol *finddepend(const symbol *parent); -symbol *addsym(const char *name,cell addr,int ident,int vclass,int tag, int usage); -symbol *addvariable(const char *name,cell addr,int ident,int vclass,int tag, - int dim[],int numdim,int idxtag[]); -symbol *addvariable2(const char *name,cell addr,int ident,int vclass,int tag, - int dim[],int numdim,int idxtag[],int slength); -symbol *addvariable3(declinfo_t *decl,cell addr,int vclass,int slength); -int getlabel(void); -char *itoh(ucell val); - -#define MATCHTAG_COERCE 0x1 // allow coercion -#define MATCHTAG_SILENT 0x2 // silence the error(213) warning -#define MATCHTAG_COMMUTATIVE 0x4 // order does not matter -#define MATCHTAG_DEDUCE 0x8 // correct coercion - -/* function prototypes in SC3.C */ -int check_userop(void (*oper)(void),int tag1,int tag2,int numparam, - value *lval,int *resulttag); -int matchtag(int formaltag,int actualtag,int allowcoerce); -int checktag(int tags[],int numtags,int exprtag); -int expression(cell *val,int *tag,symbol **symptr,int chkfuncresult,value *_lval); -int sc_getstateid(constvalue **automaton,constvalue **state); -cell array_totalsize(symbol *sym); -int matchtag_string(int ident, int tag); -int checktag_string(value *sym1, value *sym2); -int checktags_string(int tags[], int numtags, value *sym1); -int lvalexpr(svalue *sval); - -/* function prototypes in SC4.C */ -void writeleader(symbol *root); -void writetrailer(void); -void begcseg(void); -void begdseg(void); -void setline(int chkbounds); -void setfiledirect(char *name); -void setlinedirect(int line); -void setlabel(int index); -void markexpr(optmark type,const char *name,cell offset); -void startfunc(char *fname); -void endfunc(void); -void alignframe(int numbytes); -void rvalue(value *lval); -void address(symbol *ptr,regid reg); -void store(value *lval); -void loadreg(cell address,regid reg); -void storereg(cell address,regid reg); -void memcopy(cell size); -void copyarray(symbol *sym,cell size); -void fillarray(symbol *sym,cell size,cell value); -void ldconst(cell val,regid reg); -void moveto1(void); -void move_alt(void); -void pushreg(regid reg); -void pushval(cell val); -void popreg(regid reg); -void genarray(int dims, int _autozero); -void swap1(void); -void ffswitch(int label); -void ffcase(cell value,char *labelname,int newtable); -void ffcall(symbol *sym,const char *label,int numargs); -void ffret(int remparams); -void ffabort(int reason); -void ffbounds(cell size); -void jumplabel(int number); -void defstorage(void); -void modstk(int delta); -void setstk(cell value); -void modheap(int delta); -void modheap_i(); -void setheap_pri(void); -void setheap(cell value); -void cell2addr(void); -void cell2addr_alt(void); -void addr2cell(void); -void char2addr(void); -void charalign(void); -void addconst(cell value); -void setheap_save(cell value); -void stradjust(regid reg); -void invoke_getter(struct methodmap_method_s *method); -void invoke_setter(struct methodmap_method_s *method, int save); -void inc_pri(); -void dec_pri(); -void load_hidden_arg(); - -/* Code generation functions for arithmetic operators. - * - * Syntax: o[u|s|b]_name - * | | | +--- name of operator - * | | +----- underscore - * | +--------- "u"nsigned operator, "s"igned operator or "b"oth - * +------------- "o"perator - */ -void os_mult(void); /* multiplication (signed) */ -void os_div(void); /* division (signed) */ -void os_mod(void); /* modulus (signed) */ -void ob_add(void); /* addition */ -void ob_sub(void); /* subtraction */ -void ob_sal(void); /* shift left (arithmetic) */ -void os_sar(void); /* shift right (arithmetic, signed) */ -void ou_sar(void); /* shift right (logical, unsigned) */ -void ob_or(void); /* bitwise or */ -void ob_xor(void); /* bitwise xor */ -void ob_and(void); /* bitwise and */ -void ob_eq(void); /* equality */ -void ob_ne(void); /* inequality */ -void relop_prefix(void); -void relop_suffix(void); -void os_le(void); /* less or equal (signed) */ -void os_ge(void); /* greater or equal (signed) */ -void os_lt(void); /* less (signed) */ -void os_gt(void); /* greater (signed) */ - -void lneg(void); -void neg(void); -void invert(void); -void nooperation(void); -void inc(value *lval); -void dec(value *lval); -void jmp_ne0(int number); -void jmp_eq0(int number); -void outval(cell val,int newline); - -/* function prototypes in SC5.C */ -int error(int number,...); -void errorset(int code,int line); - -/* function prototypes in SC6.C */ -void assemble(const char *outname, void *fin); - -/* function prototypes in SC7.C */ -void stgbuffer_cleanup(void); -void stgmark(char mark); -void stgwrite(const char *st); -void stgout(int index); -void stgdel(int index,cell code_index); -int stgget(int *index,cell *code_index); -void stgset(int onoff); -int phopt_init(void); -int phopt_cleanup(void); - -/* function prototypes in SCLIST.C */ -char* duplicatestring(const char* sourcestring); -stringpair *insert_alias(char *name,char *alias); -stringpair *find_alias(char *name); -int lookup_alias(char *target,char *name); -void delete_aliastable(void); -stringlist *insert_path(char *path); -char *get_path(int index); -void delete_pathtable(void); -stringpair *insert_subst(const char *pattern,const char *substitution,int prefixlen); -int get_subst(int index,char **pattern,char **substitution); -stringpair *find_subst(char *name,int length); -int delete_subst(char *name,int length); -void delete_substtable(void); -stringlist *insert_sourcefile(char *string); -char *get_sourcefile(int index); -void delete_sourcefiletable(void); -stringlist *insert_docstring(char *string); -char *get_docstring(int index); -void delete_docstring(int index); -void delete_docstringtable(void); -stringlist *insert_autolist(const char *string); -char *get_autolist(int index); -void delete_autolisttable(void); -stringlist *insert_dbgfile(const char *filename); -stringlist *insert_dbgline(int linenr); -stringlist *insert_dbgsymbol(symbol *sym); -char *get_dbgstring(int index); -void delete_dbgstringtable(void); -stringlist *get_dbgstrings(); - -/* function prototypes in SCI18N.C */ -#define MAXCODEPAGE 12 -int cp_path(const char *root,const char *directory); -int cp_set(const char *name); -cell cp_translate(const unsigned char *string,const unsigned char **endptr); -cell get_utf8_char(const unsigned char *string,const unsigned char **endptr); -int scan_utf8(void *fp,const char *filename); - -/* function prototypes in SCSTATE.C */ -constvalue *automaton_add(const char *name); -constvalue *automaton_find(const char *name); -constvalue *automaton_findid(int id); -constvalue *state_add(const char *name,int fsa_id); -constvalue *state_find(const char *name,int fsa_id); -constvalue *state_findid(int id); -void state_buildlist(int **list,int *listsize,int *count,int stateid); -int state_addlist(int *list,int count,int fsa_id); -void state_deletetable(void); -int state_getfsa(int listid); -int state_count(int listid); -int state_inlist(int listid,int state); -int state_listitem(int listid,int index); -void state_conflict(symbol *root); -int state_conflict_id(int listid1,int listid2); - -/* external variables (defined in scvars.c) */ -#if !defined SC_SKIP_VDECL -typedef struct HashTable HashTable; -extern struct HashTable *sp_Globals; -extern symbol loctab; /* local symbol table */ -extern symbol glbtab; /* global symbol table */ -extern cell *litq; /* the literal queue */ -extern unsigned char pline[]; /* the line read from the input file */ -extern const unsigned char *lptr;/* points to the current position in "pline" */ -extern constvalue tagname_tab;/* tagname table */ -extern constvalue libname_tab;/* library table (#pragma library "..." syntax) */ -extern constvalue *curlibrary;/* current library */ -extern int pc_addlibtable; /* is the library table added to the AMX file? */ -extern symbol *curfunc; /* pointer to current function */ -extern char *inpfname; /* name of the file currently read from */ -extern char outfname[]; /* intermediate (assembler) file name */ -extern char binfname[]; /* binary file name */ -extern char errfname[]; /* error file name */ -extern char sc_ctrlchar; /* the control character (or escape character) */ -extern char sc_ctrlchar_org;/* the default control character */ -extern int litidx; /* index to literal table */ -extern int litmax; /* current size of the literal table */ -extern int stgidx; /* index to the staging buffer */ -extern int sc_labnum; /* number of (internal) labels */ -extern int staging; /* true if staging output */ -extern cell declared; /* number of local cells declared */ -extern cell glb_declared; /* number of global cells declared */ -extern cell code_idx; /* number of bytes with generated code */ -extern int ntv_funcid; /* incremental number of native function */ -extern int errnum; /* number of errors */ -extern int warnnum; /* number of warnings */ -extern int sc_debug; /* debug/optimization options (bit field) */ -extern int sc_packstr; /* strings are packed by default? */ -extern int sc_asmfile; /* create .ASM file? */ -extern int sc_listing; /* create .LST file? */ -extern int sc_compress; /* compress bytecode? */ -extern int sc_needsemicolon;/* semicolon required to terminate expressions? */ -extern int sc_dataalign; /* data alignment value */ -extern int sc_alignnext; /* must frame of the next function be aligned? */ -extern int pc_docexpr; /* must expression be attached to documentation comment? */ -extern int sc_showincludes; /* show include files? */ -extern int curseg; /* 1 if currently parsing CODE, 2 if parsing DATA */ -extern cell pc_stksize; /* stack size */ -extern cell pc_amxlimit; /* abstract machine size limit (code + data, or only code) */ -extern cell pc_amxram; /* abstract machine data size limit */ -extern int freading; /* is there an input file ready for reading? */ -extern int fline; /* the line number in the current file */ -extern short fnumber; /* number of files in the file table (debugging) */ -extern short fcurrent; /* current file being processed (debugging) */ -extern short sc_intest; /* true if inside a test */ -extern int sideeffect; /* true if an expression causes a side-effect */ -extern int stmtindent; /* current indent of the statement */ -extern int indent_nowarn; /* skip warning "217 loose indentation" */ -extern int sc_tabsize; /* number of spaces that a TAB represents */ -extern short sc_allowtags; /* allow/detect tagnames in lex() */ -extern int sc_status; /* read/write status */ -extern int sc_err_status; /* TRUE if errors should be generated even if sc_status = SKIP */ -extern int sc_rationaltag; /* tag for rational numbers */ -extern int rational_digits; /* number of fractional digits */ -extern int sc_allowproccall;/* allow/detect tagnames in lex() */ -extern short sc_is_utf8; /* is this source file in UTF-8 encoding */ -extern char *pc_deprecate; /* if non-NULL, mark next declaration as deprecated */ -extern int sc_curstates; /* ID of the current state list */ -extern int pc_optimize; /* (peephole) optimization level */ -extern int pc_memflags; /* special flags for the stack/heap usage */ -extern int pc_functag; /* global function tag */ -extern int pc_tag_string; /* global String tag */ -extern int pc_tag_void; /* global void tag */ -extern int pc_tag_object; /* root object tag */ -extern int pc_tag_bool; /* global bool tag */ -extern int pc_tag_null_t; /* the null type */ -extern int pc_tag_nullfunc_t; /* the null function type */ -extern int pc_anytag; /* global any tag */ -extern int glbstringread; /* last global string read */ -extern int sc_require_newdecls; /* only newdecls are allowed */ -extern bool sc_warnings_are_errors; - -extern constvalue sc_automaton_tab; /* automaton table */ -extern constvalue sc_state_tab; /* state table */ - -extern void *inpf; /* file read from (source or include) */ -extern void *inpf_org; /* main source file */ -extern void *outf; /* file written to */ - -extern jmp_buf errbuf; /* target of longjmp() on a fatal error */ - -#if !defined SC_LIGHT - extern int sc_makereport; /* generate a cross-reference report */ -#endif - -#if defined WIN32 -# if !defined snprintf -# define snprintf _snprintf -# define vsnprintf _vsnprintf -# endif -#endif - -#endif /* SC_SKIP_VDECL */ - -typedef struct array_info_s -{ - const int *dim_list; /* Dimension sizes */ - int dim_count; /* Number of dimensions */ - const int *lastdim_list; /* Sizes of last dimensions, if variable */ - const cell *dim_offs_precalc; /* Cached calculations into the lastdim_list array */ - cell *data_offs; /* Current offset AFTER the indirection vectors (data) */ - int *cur_dims; /* Current dimensions the recursion is at */ - cell *base; /* &litq[startlit] */ -} array_info_t; - -enum FatalError { - FIRST_FATAL_ERROR = 180, - - FATAL_ERROR_READ = FIRST_FATAL_ERROR, - FATAL_ERROR_WRITE, - FATAL_ERROR_ALLOC_OVERFLOW, - FATAL_ERROR_OOM, - FATAL_ERROR_INVALID_INSN, - FATAL_ERROR_INT_OVERFLOW, - FATAL_ERROR_SCRIPT_OVERFLOW, - FATAL_ERROR_OVERWHELMED_BY_BAD, - FATAL_ERROR_NO_CODEPAGE, - FATAL_ERROR_INVALID_PATH, - FATAL_ERROR_ASSERTION_FAILED, - FATAL_ERROR_USER_ERROR, - - FATAL_ERRORS_TOTAL -}; - -struct AutoDisableLiteralQueue -{ - public: - AutoDisableLiteralQueue(); - ~AutoDisableLiteralQueue(); - - private: - bool prev_value_; -}; - -#endif /* SC_H_INCLUDED */ diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp deleted file mode 100644 index ec76e3d3..00000000 --- a/sourcepawn/compiler/sc1.cpp +++ /dev/null @@ -1,8028 +0,0 @@ -/* vim: set sts=2 ts=8 sw=2 tw=99 et: */ -/* Pawn compiler - * - * Function and variable definition and declaration, statement parser. - * - * Copyright (c) ITB CompuPhase, 1997-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include -#include -#include -#include -#include -#include - -#if defined __WIN32__ || defined _WIN32 || defined __MSDOS__ - #include - #include -#endif - -#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined DARWIN - #include - #include /* from BinReloc, see www.autopackage.org */ - #include -#endif - -#if defined FORTIFY - #include -#endif - -#if defined __BORLANDC__ || defined __WATCOMC__ - #include - static unsigned total_drives; /* dummy variable */ - #define dos_setdrive(i) _dos_setdrive(i,&total_drives) -#elif defined _MSC_VER && defined _WIN32 - #include /* for _chdrive() */ - #define dos_setdrive(i) _chdrive(i) -#endif -#if defined __BORLANDC__ - #include /* for chdir() */ -#elif defined __WATCOMC__ - #include /* for chdir() */ -#endif -#if defined __WIN32__ || defined _WIN32 || defined _Windows - #include -#endif - -#include - -#include "lstring.h" -#include "sc.h" -#include -#include "sctracker.h" -#include "sp_symhash.h" -#define VERSION_STR "3.2.3636" -#define VERSION_INT 0x0302 - -int pc_anytag = 0; -int pc_functag = 0; -int pc_tag_string = 0; -int pc_tag_void = 0; -int pc_tag_object = 0; -int pc_tag_bool = 0; -int pc_tag_null_t = 0; -int pc_tag_nullfunc_t = 0; - -static void resetglobals(void); -static void initglobals(void); -static char *get_extension(char *filename); -static void setopt(int argc,char **argv,char *oname,char *ename,char *pname, - char *rname,char *codepage); -static void setconfig(char *root); -static void setcaption(void); -static void about(void); -static void setconstants(void); -static void parse(void); -static void dumplits(void); -static void dumpzero(int count); -static void declglb(declinfo_t *decl,int fpublic,int fstatic,int stock); -static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct); -static void declloc(int tokid); -static void dodelete(); -static void decl_const(int table); -static void declstruct(); -static void decl_enum(int table); -static cell needsub(int *tag,constvalue **enumroot); -static void initials(int ident,int tag,cell *size,int dim[],int numdim, - constvalue *enumroot); -static cell initarray(int ident,int tag,int dim[],int numdim,int cur, - int startlit,int counteddim[],constvalue *lastdim, - constvalue *enumroot,int *errorfound); -static cell initvector(int ident,int tag,cell size,int fillzero, - constvalue *enumroot,int *errorfound); -static void initials3(declinfo_t *decl); -static cell fix_char_size(declinfo_t *decl); -static cell init(int ident,int *tag,int *errorfound); -static int getstates(const char *funcname); -static void attachstatelist(symbol *sym, int state_id); -static symbol *funcstub(int tokid, declinfo_t *decl, const int *thistag); -static int newfunc(declinfo_t *decl, const int *thistag, int fpublic, int fstatic, int stock, symbol **symp); -static int declargs(symbol *sym, int chkshadow, const int *thistag); -static void doarg(declinfo_t *decl, int offset, int fpublic, int chkshadow, arginfo *arg); -static void make_report(symbol *root,FILE *log,char *sourcefile); -static void reduce_referrers(symbol *root); -static long max_stacksize(symbol *root,int *recursion); -static int testsymbols(symbol *root,int level,int testlabs,int testconst); -static void destructsymbols(symbol *root,int level); -static constvalue *find_constval_byval(constvalue *table,cell val); -static symbol *fetchlab(char *name); -static void statement(int *lastindent,int allow_decl); -static void compound(int stmt_sameline,int starttok); -static int test(int label,int parens,int invert); -static int doexpr(int comma,int chkeffect,int allowarray,int mark_endexpr, - int *tag,symbol **symptr,int chkfuncresult); -static int doexpr2(int comma,int chkeffect,int allowarray,int mark_endexpr, - int *tag,symbol **symptr,int chkfuncresult,value *lval); -static void doassert(void); -static void doexit(void); -static int doif(void); -static int dowhile(void); -static int dodo(void); -static int dofor(void); -static void doswitch(void); -static void dogoto(void); -static void dolabel(void); -static void doreturn(void); -static void dofuncenum(int listmode); -static void dotypedef(); -static void dotypeset(); -static void domethodmap(LayoutSpec spec); -static void dobreak(void); -static void docont(void); -static void dosleep(void); -static void dostate(void); -static void addwhile(int *ptr); -static void delwhile(void); -static int *readwhile(void); -static void inst_datetime_defines(void); -static void inst_binary_name(char *binfname); -static int operatorname(char *name); -static int parse_new_typename(const token_t *tok); -static int parse_new_decl(declinfo_t *decl, const token_t *first, int flags); -static int reparse_old_decl(declinfo_t *decl, int flags); -static int reparse_new_decl(declinfo_t *decl, int flags); -static void check_void_decl(const declinfo_t *decl, int variable); - -enum { - TEST_PLAIN, /* no parentheses */ - TEST_THEN, /* '(' ')' or 'then' */ - TEST_DO, /* '(' ')' or 'do' */ - TEST_OPT, /* '(' ')' or */ -}; -static int norun = 0; /* the compiler never ran */ -static int autozero = 1; /* if 1 will zero out the variable, if 0 omit the zeroing */ -static int lastst = 0; /* last executed statement type */ -static int nestlevel = 0; /* number of active (open) compound statements */ -static int endlessloop= 0; /* nesting level of endless loop */ -static int rettype = 0; /* the type that a "return" expression should have */ -static int skipinput = 0; /* number of lines to skip from the first input file */ -static int optproccall = TRUE; /* support "procedure call" */ -static int verbosity = 1; /* verbosity level, 0=quiet, 1=normal, 2=verbose */ -static int sc_reparse = 0; /* needs 3th parse because of changed prototypes? */ -static int sc_parsenum = 0; /* number of the extra parses */ -static int wq[wqTABSZ]; /* "while queue", internal stack for nested loops */ -static int *wqptr; /* pointer to next entry */ -#if !defined SC_LIGHT - static char sc_rootpath[_MAX_PATH]; - static char *sc_documentation=NULL;/* main documentation */ -#endif -#if defined __WIN32__ || defined _WIN32 || defined _Windows - static HWND hwndFinish = 0; -#endif - -int glbstringread = 0; -char g_tmpfile[_MAX_PATH] = {0}; - -/* "main" of the compiler - */ -int pc_compile(int argc, char *argv[]) -{ - int entry,i,jmpcode; - int retcode; - char incfname[_MAX_PATH]; - char reportname[_MAX_PATH]; - char codepage[MAXCODEPAGE+1]; - void *inpfmark; - int lcl_packstr,lcl_needsemicolon,lcl_tabsize,lcl_require_newdecls; - char *ptr; - - /* set global variables to their initial value */ - initglobals(); - errorset(sRESET,0); - errorset(sEXPRRELEASE,0); - lexinit(); - - /* make sure that we clean up on a fatal error; do this before the first - * call to error(). */ - if ((jmpcode=setjmp(errbuf))!=0) - goto cleanup; - - sp_Globals = NewHashTable(); - if (!sp_Globals) - error(FATAL_ERROR_OOM); - - /* allocate memory for fixed tables */ - inpfname=(char*)malloc(_MAX_PATH); - if (inpfname==NULL) - error(FATAL_ERROR_OOM); /* insufficient memory */ - litq=(cell*)malloc(litmax*sizeof(cell)); - if (litq==NULL) - error(FATAL_ERROR_OOM); /* insufficient memory */ - if (!phopt_init()) - error(FATAL_ERROR_OOM); /* insufficient memory */ - - setopt(argc,argv,outfname,errfname,incfname,reportname,codepage); - strcpy(binfname,outfname); - ptr=get_extension(binfname); - if (ptr!=NULL && stricmp(ptr,".asm")==0) - set_extension(binfname,".smx",TRUE); - else - set_extension(binfname,".smx",FALSE); - /* set output names that depend on the input name */ - if (sc_listing) - set_extension(outfname,".lst",TRUE); - else - set_extension(outfname,".asm",TRUE); - if (strlen(errfname)!=0) - remove(errfname); /* delete file on startup */ - else if (verbosity>0) - setcaption(); - setconfig(argv[0]); /* the path to the include and codepage files */ - sc_ctrlchar_org=sc_ctrlchar; - lcl_packstr=sc_packstr; - lcl_needsemicolon=sc_needsemicolon; - lcl_require_newdecls=sc_require_newdecls; - lcl_tabsize=sc_tabsize; - #if !defined NO_CODEPAGE - if (!cp_set(codepage)) /* set codepage */ - error(FATAL_ERROR_NO_CODEPAGE); - #endif - /* optionally create a temporary input file that is a collection of all - * input files - */ - assert(get_sourcefile(0)!=NULL); /* there must be at least one source file */ - if (get_sourcefile(1)!=NULL) { - /* there are at least two or more source files */ - char *tname,*sname; - void *ftmp,*fsrc; - int fidx; - #if defined __WIN32__ || defined _WIN32 - tname=_tempnam(NULL,"pawn"); - #elif defined __MSDOS__ || defined _Windows - tname=tempnam(NULL,"pawn"); - #elif defined(MACOS) && !defined(__MACH__) - /* tempnam is not supported for the Macintosh CFM build. */ - error(FATAL_ERROR_INVALID_INSN,get_sourcefile(1)); - tname=NULL; - sname=NULL; - #else - char *buffer = strdup(P_tmpdir "/pawn.XXXXXX"); - close(mkstemp(buffer)); - tname=buffer; - #endif - ftmp=pc_createsrc(tname); - for (fidx=0; (sname=get_sourcefile(fidx))!=NULL; fidx++) { - unsigned char tstring[128]; - fsrc=pc_opensrc(sname); - if (fsrc==NULL) { - pc_closesrc(ftmp); - remove(tname); - strcpy(inpfname,sname); /* avoid invalid filename */ - error(FATAL_ERROR_READ,sname); - } /* if */ - pc_writesrc(ftmp,(unsigned char*)"#file \""); - pc_writesrc(ftmp,(unsigned char*)sname); - pc_writesrc(ftmp,(unsigned char*)"\"\n"); - while (!pc_eofsrc(fsrc) && pc_readsrc(fsrc,tstring,sizeof tstring)) { - pc_writesrc(ftmp,tstring); - } /* while */ - pc_closesrc(fsrc); - } /* for */ - pc_closesrc(ftmp); - strcpy(inpfname,tname); - strcpy(g_tmpfile,tname); - free(tname); - } else { - strcpy(inpfname,get_sourcefile(0)); - } /* if */ - inpf_org=pc_opensrc(inpfname); - if (inpf_org==NULL) - error(FATAL_ERROR_READ,inpfname); - freading=TRUE; - outf=(FILE*)pc_openasm(outfname); /* first write to assembler file (may be temporary) */ - if (outf==NULL) - error(FATAL_ERROR_WRITE,outfname); - setconstants(); /* set predefined constants and tagnames */ - for (i=0; i0) { - if (strcmp(incfname,sDEF_PREFIX)==0) { - plungefile(incfname,FALSE,TRUE); /* parse "default.inc" */ - } else { - if (!plungequalifiedfile(incfname)) /* parse "prefix" include file */ - error(FATAL_ERROR_READ,incfname); - } /* if */ - } /* if */ - preprocess(); /* fetch first line */ - parse(); /* process all input */ - sc_parsenum++; - } while (sc_reparse); - - /* second (or third) pass */ - sc_status=statWRITE; /* set, to enable warnings */ - state_conflict(&glbtab); - - /* write a report, if requested */ - #if !defined SC_LIGHT - if (sc_makereport) { - FILE *frep=stdout; - if (strlen(reportname)>0) - frep=fopen(reportname,"wb"); /* avoid translation of \n to \r\n in DOS/Windows */ - if (frep!=NULL) { - make_report(&glbtab,frep,get_sourcefile(0)); - if (strlen(reportname)>0) - fclose(frep); - } /* if */ - if (sc_documentation!=NULL) { - free(sc_documentation); - sc_documentation=NULL; - } /* if */ - } /* if */ - #endif - if (sc_listing) - goto cleanup; - - /* ??? for re-parsing the listing file instead of the original source - * file (and doing preprocessing twice): - * - close input file, close listing file - * - re-open listing file for reading (inpf) - * - open assembler file (outf) - */ - - /* reset "defined" flag of all functions and global variables */ - reduce_referrers(&glbtab); - delete_symbols(&glbtab,0,TRUE,FALSE); - funcenums_free(); - methodmaps_free(); - pstructs_free(); - #if !defined NO_DEFINE - delete_substtable(); - inst_datetime_defines(); - inst_binary_name(binfname); - #endif - resetglobals(); - sc_ctrlchar=sc_ctrlchar_org; - sc_packstr=lcl_packstr; - sc_needsemicolon=lcl_needsemicolon; - sc_require_newdecls=lcl_require_newdecls; - sc_tabsize=lcl_tabsize; - errorset(sRESET,0); - /* reset the source file */ - inpf=inpf_org; - freading=TRUE; - pc_resetsrc(inpf,inpfmark); /* reset file position */ - fline=skipinput; /* reset line number */ - lexinit(); /* clear internal flags of lex() */ - sc_status=statWRITE; /* allow to write --this variable was reset by resetglobals() */ - writeleader(&glbtab); - insert_dbgfile(inpfname); - if (strlen(incfname)>0) { - if (strcmp(incfname,sDEF_PREFIX)==0) - plungefile(incfname,FALSE,TRUE); /* parse "default.inc" (again) */ - else - plungequalifiedfile(incfname); /* parse implicit include file (again) */ - } /* if */ - preprocess(); /* fetch first line */ - parse(); /* process all input */ - /* inpf is already closed when readline() attempts to pop of a file */ - writetrailer(); /* write remaining stuff */ - - entry=testsymbols(&glbtab,0,TRUE,FALSE); /* test for unused or undefined - * functions and variables */ - if (!entry) - error(13); /* no entry point (no public functions) */ - -cleanup: - if (inpf!=NULL) /* main source file is not closed, do it now */ - pc_closesrc(inpf); - - // Write the binary file. - if (!(sc_asmfile || sc_listing) && errnum==0 && jmpcode==0) { - pc_resetasm(outf); - assemble(binfname, outf); - } - - if (outf!=NULL) { - pc_closeasm(outf,!(sc_asmfile || sc_listing)); - outf=NULL; - } /* if */ - -#if !defined SC_LIGHT - if (errnum==0 && strlen(errfname)==0) { -# if 0 //bug in compiler -- someone's script caused this function to infrecurs - int recursion; - long stacksize=max_stacksize(&glbtab,&recursion); -# endif - int flag_exceed=0; - if (pc_amxlimit>0) { - long totalsize=code_idx; - if (pc_amxram==0) - totalsize+=(glb_declared+pc_stksize)*sizeof(cell); - if (totalsize>=pc_amxlimit) - flag_exceed=1; - } /* if */ - if (pc_amxram>0 && (glb_declared+pc_stksize)*sizeof(cell)>=(unsigned long)pc_amxram) - flag_exceed=1; - if ((!norun && (sc_debug & sSYMBOLIC)!=0) || verbosity>=2 || flag_exceed) { - pc_printf("Code size: %8ld bytes\n", (long)code_idx); - pc_printf("Data size: %8ld bytes\n", (long)glb_declared*sizeof(cell)); - pc_printf("Stack/heap size: %8ld bytes\n", (long)pc_stksize*sizeof(cell)); - pc_printf("Total requirements:%8ld bytes\n", (long)code_idx+(long)glb_declared*sizeof(cell)+(long)pc_stksize*sizeof(cell)); - } /* if */ - if (flag_exceed) - error(FATAL_ERROR_INT_OVERFLOW,pc_amxlimit+pc_amxram); /* this causes a jump back to label "cleanup" */ - } /* if */ - #endif - - if (g_tmpfile[0] != '\0') { - remove(g_tmpfile); - } - if (inpfname!=NULL) { - free(inpfname); - } /* if */ - if (litq!=NULL) - free(litq); - phopt_cleanup(); - stgbuffer_cleanup(); - clearstk(); - assert(jmpcode!=0 || loctab.next==NULL);/* on normal flow, local symbols - * should already have been deleted */ - delete_symbols(&loctab,0,TRUE,TRUE); /* delete local variables if not yet - * done (i.e. on a fatal error) */ - delete_symbols(&glbtab,0,TRUE,TRUE); - DestroyHashTable(sp_Globals); - delete_consttable(&tagname_tab); - delete_consttable(&libname_tab); - delete_consttable(&sc_automaton_tab); - delete_consttable(&sc_state_tab); - state_deletetable(); - delete_aliastable(); - delete_pathtable(); - delete_sourcefiletable(); - delete_dbgstringtable(); - funcenums_free(); - methodmaps_free(); - pstructs_free(); - #if !defined NO_DEFINE - delete_substtable(); - #endif - #if !defined SC_LIGHT - delete_docstringtable(); - if (sc_documentation!=NULL) - free(sc_documentation); - #endif - delete_autolisttable(); - if (errnum!=0) { - if (strlen(errfname)==0) - pc_printf("\n%d Error%s.\n",errnum,(errnum>1) ? "s" : ""); - retcode=1; - } else if (warnnum!=0){ - if (strlen(errfname)==0) - pc_printf("\n%d Warning%s.\n",warnnum,(warnnum>1) ? "s" : ""); - retcode=0; /* use "0", so that MAKE and similar tools continue */ - } else { - retcode=jmpcode; - if (retcode==0 && verbosity>=2) - pc_printf("\nDone.\n"); - } /* if */ - #if defined __WIN32__ || defined _WIN32 || defined _Windows - if (IsWindow(hwndFinish)) - PostMessageA(hwndFinish,RegisterWindowMessageA("PawnNotify"),retcode,0L); - #endif - #if defined FORTIFY - Fortify_ListAllMemory(); - #endif - return retcode; -} - -int pc_addconstant(const char *name,cell value,int tag) -{ - errorset(sFORCESET,0); /* make sure error engine is silenced */ - sc_status=statIDLE; - add_constant(name,value,sGLOBAL,tag); - return 1; -} - -static void inst_binary_name(char *binfname) -{ - size_t i, len; - char *binptr; - char newpath[512], newname[512]; - - binptr = NULL; - len = strlen(binfname); - for (i = len - 1; i < len; i--) - { - if (binfname[i] == '/' -#if defined WIN32 || defined _WIN32 - || binfname[i] == '\\' -#endif - ) - { - binptr = &binfname[i + 1]; - break; - } - } - - if (binptr == NULL) - { - binptr = binfname; - } - - snprintf(newpath, sizeof(newpath), "\"%s\"", binfname); - snprintf(newname, sizeof(newname), "\"%s\"", binptr); - - insert_subst("__BINARY_PATH__", newpath, 15); - insert_subst("__BINARY_NAME__", newname, 15); -} - -static void inst_datetime_defines(void) -{ - char date[64]; - char ltime[64]; - time_t td; - struct tm *curtime; - - time(&td); - curtime = localtime(&td); - -#if defined EMSCRIPTEN - snprintf(date, sizeof(date), "\"%02d/%02d/%04d\"", curtime->tm_mon + 1, curtime->tm_mday, curtime->tm_year + 1900); - snprintf(ltime, sizeof(ltime), "\"%02d:%02d:%02d\"", curtime->tm_hour, curtime->tm_min, curtime->tm_sec); -#else - strftime(date, 31, "\"%m/%d/%Y\"", curtime); - strftime(ltime, 31, "\"%H:%M:%S\"", curtime); -#endif - - insert_subst("__DATE__", date, 8); - insert_subst("__TIME__", ltime, 8); -} - -const char *pc_typename(int tag) -{ - if (tag == 0) - return "int"; - if (tag == sc_rationaltag) - return "float"; - if (tag == pc_tag_string) - return "char"; - return pc_tagname(tag); -} - -const char *pc_tagname(int tag) -{ - constvalue *ptr=tagname_tab.next; - for (; ptr; ptr=ptr->next) { - if (TAGID(ptr->value) == TAGID(tag)) - return ptr->name; - } - return "__unknown__"; -} - -constvalue *pc_tagptr(const char *name) -{ - constvalue *ptr=tagname_tab.next; - for (; ptr; ptr=ptr->next) { - if (strcmp(name, ptr->name)==0) - return ptr; - } - return NULL; -} - -int pc_findtag(const char *name) -{ - constvalue *ptr=tagname_tab.next; - for (; ptr; ptr=ptr->next) { - if (strcmp(name,ptr->name)==0) - return ptr->value; - } - return -1; -} - -int pc_addtag(const char *name) -{ - int val; - int flags = 0; - - if (name==NULL) { - /* no tagname was given, check for one */ - char *nameptr; - if (lex(&val,&nameptr)!=tLABEL) { - lexpush(); - return 0; /* untagged */ - } /* if */ - name = nameptr; - } /* if */ - - if (isupper(*name)) - flags |= FIXEDTAG; - - return pc_addtag_flags(name, flags); -} - -int pc_addtag_flags(const char *name, int flags) -{ - constvalue *ptr; - int last; - - assert((flags & FUNCTAG) || strchr(name,':')==NULL); /* colon should already have been stripped */ - last=0; - ptr=tagname_tab.next; - while (ptr!=NULL) { - if (strcmp(name,ptr->name)==0) { - // Update the flag set. - ptr->value |= flags; - return ptr->value; - } - if (TAGID(ptr->value) > last) - last = TAGID(ptr->value); - ptr = ptr->next; - } /* while */ - - /* tagname currently unknown, add it */ - int tag = (last + 1) | flags; - append_constval(&tagname_tab, name, (cell)tag, 0); - return tag; -} - -static void resetglobals(void) -{ - /* reset the subset of global variables that is modified by the first pass */ - curfunc=NULL; /* pointer to current function */ - lastst=0; /* last executed statement type */ - nestlevel=0; /* number of active (open) compound statements */ - rettype=0; /* the type that a "return" expression should have */ - litidx=0; /* index to literal table */ - stgidx=0; /* index to the staging buffer */ - sc_labnum=0; /* top value of (internal) labels */ - staging=0; /* true if staging output */ - declared=0; /* number of local cells declared */ - glb_declared=0; /* number of global cells declared */ - code_idx=0; /* number of bytes with generated code */ - ntv_funcid=0; /* incremental number of native function */ - curseg=0; /* 1 if currently parsing CODE, 2 if parsing DATA */ - freading=FALSE; /* no input file ready yet */ - fline=0; /* the line number in the current file */ - fnumber=0; /* the file number in the file table (debugging) */ - fcurrent=0; /* current file being processed (debugging) */ - sc_intest=FALSE; /* true if inside a test */ - sideeffect=0; /* true if an expression causes a side-effect */ - stmtindent=0; /* current indent of the statement */ - indent_nowarn=FALSE; /* do not skip warning "217 loose indentation" */ - sc_allowtags=TRUE; /* allow/detect tagnames */ - sc_status=statIDLE; - sc_allowproccall=FALSE; - pc_addlibtable=TRUE; /* by default, add a "library table" to the output file */ - sc_alignnext=FALSE; - pc_docexpr=FALSE; - pc_deprecate=NULL; - sc_curstates=0; - pc_memflags=0; -} - -static void initglobals(void) -{ - resetglobals(); - - sc_asmfile=FALSE; /* do not create .ASM file */ - sc_listing=FALSE; /* do not create .LST file */ - skipinput=0; /* number of lines to skip from the first input file */ - sc_ctrlchar=CTRL_CHAR;/* the escape character */ - litmax=sDEF_LITMAX; /* current size of the literal table */ - errnum=0; /* number of errors */ - warnnum=0; /* number of warnings */ - optproccall=FALSE; /* sourcemod: do not support "procedure call" */ - verbosity=1; /* verbosity level, no copyright banner */ - sc_debug=sCHKBOUNDS|sSYMBOLIC; /* sourcemod: full debug stuff */ - pc_optimize=sOPTIMIZE_DEFAULT; /* sourcemod: full optimization */ - sc_packstr=TRUE; /* strings are packed by default */ - sc_compress=FALSE; /* always disable compact encoding! */ - sc_needsemicolon=FALSE;/* semicolon required to terminate expressions? */ - sc_require_newdecls = FALSE; - sc_dataalign=sizeof(cell); - pc_stksize=sDEF_AMXSTACK;/* default stack size */ - pc_amxlimit=0; /* no limit on size of the abstract machine */ - pc_amxram=0; /* no limit on data size of the abstract machine */ - sc_tabsize=8; /* assume a TAB is 8 spaces */ - sc_rationaltag=0; /* assume no support for rational numbers */ - rational_digits=0; /* number of fractional digits */ - - outfname[0]='\0'; /* output file name */ - errfname[0]='\0'; /* error file name */ - inpf=NULL; /* file read from */ - inpfname=NULL; /* pointer to name of the file currently read from */ - outf=NULL; /* file written to */ - litq=NULL; /* the literal queue */ - glbtab.next=NULL; /* clear global variables/constants table */ - loctab.next=NULL; /* " local " / " " */ - tagname_tab.next=NULL;/* tagname table */ - libname_tab.next=NULL;/* library table (#pragma library "..." syntax) */ - - pline[0]='\0'; /* the line read from the input file */ - lptr=NULL; /* points to the current position in "pline" */ - curlibrary=NULL; /* current library */ - inpf_org=NULL; /* main source file */ - - wqptr=wq; /* initialize while queue pointer */ - -#if !defined SC_LIGHT - sc_documentation=NULL; - sc_makereport=FALSE; /* do not generate a cross-reference report */ -#endif -} - -static char *get_extension(char *filename) -{ - char *ptr; - - assert(filename!=NULL); - ptr=strrchr(filename,'.'); - if (ptr!=NULL) { - /* ignore extension on a directory or at the start of the filename */ - if (strchr(ptr,DIRSEP_CHAR)!=NULL || ptr==filename || *(ptr-1)==DIRSEP_CHAR) - ptr=NULL; - } /* if */ - return ptr; -} - -/* set_extension - * Set the default extension, or force an extension. To erase the - * extension of a filename, set "extension" to an empty string. - */ -void set_extension(char *filename,const char *extension,int force) -{ - char *ptr; - - assert(extension!=NULL && (*extension=='\0' || *extension=='.')); - assert(filename!=NULL); - ptr=get_extension(filename); - if (force && ptr!=NULL) - *ptr='\0'; /* set zero terminator at the position of the period */ - if (force || ptr==NULL) - strcat(filename,extension); -} - -static const char *option_value(const char *optptr) -{ - return (*(optptr+1)=='=' || *(optptr+1)==':') ? optptr+2 : optptr+1; -} - -static int toggle_option(const char *optptr, int option) -{ - switch (*option_value(optptr)) { - case '\0': - option=!option; - break; - case '-': - option=FALSE; - break; - case '+': - option=TRUE; - break; - default: - about(); - } /* switch */ - return option; -} - -/* Parsing command line options is indirectly recursive: parseoptions() - * calls parserespf() to handle options in a a response file and - * parserespf() calls parseoptions() at its turn after having created - * an "option list" from the contents of the file. - */ -static void parserespf(char *filename,char *oname,char *ename,char *pname, - char *rname, char *codepage); - -static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pname, - char *rname, char *codepage) -{ - char str[_MAX_PATH],*name; - const char *ptr; - int arg,i,isoption; - - for (arg=1; arg1) - verbosity=1; - break; -#if 0 /* not allowed in SourceMod */ - case 'C': - #if AMX_COMPACTMARGIN > 2 - sc_compress=toggle_option(ptr,sc_compress); - #else - about(); - #endif - break; -#endif - case 'c': - strlcpy(codepage,option_value(ptr),MAXCODEPAGE); /* set name of codepage */ - break; -#if defined dos_setdrive - case 'D': /* set active directory */ - ptr=option_value(ptr); - if (ptr[1]==':') - dos_setdrive(toupper(*ptr)-'A'+1); /* set active drive */ - chdir(ptr); - break; -#endif -#if 0 /* not allowed to change for SourceMod */ - case 'd': - switch (*option_value(ptr)) { - case '0': - sc_debug=0; - break; - case '1': - sc_debug=sCHKBOUNDS; /* assertions and bounds checking */ - break; - case '2': - sc_debug=sCHKBOUNDS | sSYMBOLIC; /* also symbolic info */ - break; - case '3': - sc_debug=sCHKBOUNDS | sSYMBOLIC; - pc_optimize=sOPTIMIZE_NONE; - /* also avoid peephole optimization */ - break; - default: - about(); - } /* switch */ - break; -#endif - case 'e': - strlcpy(ename,option_value(ptr),_MAX_PATH); /* set name of error file */ - break; - case 'E': - sc_warnings_are_errors = true; - break; -#if defined __WIN32__ || defined _WIN32 || defined _Windows - case 'H': - hwndFinish=(HWND)atoi(option_value(ptr)); - if (!IsWindow(hwndFinish)) - hwndFinish=(HWND)0; - break; -#endif - case 'h': - sc_showincludes = 1; - break; - case 'i': - strlcpy(str,option_value(ptr),sizeof str); /* set name of include directory */ - i=strlen(str); - if (i>0) { - if (str[i-1]!=DIRSEP_CHAR) { - str[i]=DIRSEP_CHAR; - str[i+1]='\0'; - } /* if */ - insert_path(str); - } /* if */ - break; - case 'l': - if (*(ptr+1)!='\0') - about(); - sc_listing=TRUE; /* skip second pass & code generation */ - break; - case 'o': - strlcpy(oname,option_value(ptr),_MAX_PATH); /* set name of (binary) output file */ - break; - case 'O': - pc_optimize=*option_value(ptr) - '0'; - if (pc_optimize=sOPTIMIZE_NUMBER || pc_optimize==sOPTIMIZE_NOMACRO) - about(); - break; - case 'p': - strlcpy(pname,option_value(ptr),_MAX_PATH); /* set name of implicit include file */ - break; -#if !defined SC_LIGHT - case 'r': - strlcpy(rname,option_value(ptr),_MAX_PATH); /* set name of report file */ - sc_makereport=TRUE; - if (strlen(rname)>0) { - set_extension(rname,".xml",FALSE); - } else if ((name=get_sourcefile(0))!=NULL) { - assert(strlen(rname)==0); - assert(strlen(name)<_MAX_PATH); - if ((ptr=strrchr(name,DIRSEP_CHAR))!=NULL) - ptr++; /* strip path */ - else - ptr=name; - assert(strlen(ptr)<_MAX_PATH); - strcpy(rname,ptr); - set_extension(rname,".xml",TRUE); - } /* if */ - break; -#endif - case 'S': - i=atoi(option_value(ptr)); - if (i>32) - pc_stksize=(cell)i; /* stack size has minimum size */ - else - about(); - break; - case 's': - skipinput=atoi(option_value(ptr)); - break; - case 't': - sc_tabsize=atoi(option_value(ptr)); - break; - case 'v': - verbosity= isdigit(*option_value(ptr)) ? atoi(option_value(ptr)) : 2; - if (sc_asmfile && verbosity>1) - verbosity=1; - break; - case 'w': - i=(int)strtol(option_value(ptr),(char **)&ptr,10); - if (*ptr=='-') - pc_enablewarning(i,0); - else if (*ptr=='+') - pc_enablewarning(i,1); - else if (*ptr=='\0') - pc_enablewarning(i,2); - break; - case 'X': - if (*(ptr+1)=='D') { - i=atoi(option_value(ptr+1)); - if (i>64) - pc_amxram=(cell)i; /* abstract machine data/stack has minimum size */ - else - about(); - } else { - i=atoi(option_value(ptr)); - if (i>64) - pc_amxlimit=(cell)i;/* abstract machine has minimum size */ - else - about(); - } /* if */ - break; - case '\\': /* use \ instead for escape characters */ - sc_ctrlchar='\\'; - break; - case '^': /* use ^ instead for escape characters */ - sc_ctrlchar='^'; - break; - case ';': - sc_needsemicolon=toggle_option(ptr,sc_needsemicolon); - break; -#if 0 /* not allowed to change in SourceMod */ - case '(': - optproccall=!toggle_option(ptr,!optproccall); - break; -#endif - default: /* wrong option */ - about(); - } /* switch */ - } else if (argv[arg][0]=='@') { - #if !defined SC_LIGHT - parserespf(&argv[arg][1],oname,ename,pname,rname,codepage); - #endif - } else if ((ptr=strchr(argv[arg],'='))!=NULL) { - i=(int)(ptr-argv[arg]); - if (i>sNAMEMAX) { - i=sNAMEMAX; - error(200,argv[arg],sNAMEMAX); /* symbol too long, truncated to sNAMEMAX chars */ - } /* if */ - strlcpy(str,argv[arg],i+1); /* str holds symbol name */ - i=atoi(ptr+1); - add_constant(str,i,sGLOBAL,0); - } else { - strlcpy(str,argv[arg],sizeof(str)-5); /* -5 because default extension is ".sp" */ - set_extension(str,".sp",FALSE); - insert_sourcefile(str); - /* The output name is the first input name with a different extension, - * but it is stored in a different directory - */ - if (strlen(oname)==0) { - if ((ptr=strrchr(str,DIRSEP_CHAR))!=NULL) - ptr++; /* strip path */ - else - ptr=str; - assert(strlen(ptr)<_MAX_PATH); - strcpy(oname,ptr); - } /* if */ - set_extension(oname,".asm",TRUE); -#if !defined SC_LIGHT - if (sc_makereport && strlen(rname)==0) { - if ((ptr=strrchr(str,DIRSEP_CHAR))!=NULL) - ptr++; /* strip path */ - else - ptr=str; - assert(strlen(ptr)<_MAX_PATH); - strcpy(rname,ptr); - set_extension(rname,".xml",TRUE); - } /* if */ -#endif - } /* if */ - } /* for */ -} - -#if !defined SC_LIGHT -static void parserespf(char *filename,char *oname,char *ename,char *pname, - char *rname,char *codepage) -{ -#define MAX_OPTIONS 100 - FILE *fp; - char *string, *ptr, **argv; - int argc; - long size; - - if ((fp=fopen(filename,"r"))==NULL) - error(FATAL_ERROR_READ,filename); - /* load the complete file into memory */ - fseek(fp,0L,SEEK_END); - size=ftell(fp); - fseek(fp,0L,SEEK_SET); - assert(size [filename...] [options]\n\n"); - pc_printf("Options:\n"); - pc_printf(" -A alignment in bytes of the data segment and the stack\n"); - pc_printf(" -a output assembler code\n"); -#if 0 /* not toggleable in SourceMod */ - pc_printf(" -C[+/-] compact encoding for output file (default=%c)\n", sc_compress ? '+' : '-'); -#endif - pc_printf(" -c codepage name or number; e.g. 1252 for Windows Latin-1\n"); -#if defined dos_setdrive - pc_printf(" -Dpath active directory path\n"); -#endif -#if 0 /* not used for SourceMod */ - pc_printf(" -d debugging level (default=-d%d)\n",sc_debug); - pc_printf(" 0 no symbolic information, no run-time checks\n"); - pc_printf(" 1 run-time checks, no symbolic information\n"); - pc_printf(" 2 full debug information and dynamic checking\n"); - pc_printf(" 3 same as -d2, but implies -O0\n"); -#endif - pc_printf(" -e set name of error file (quiet compile)\n"); -#if defined __WIN32__ || defined _WIN32 || defined _Windows - pc_printf(" -H window handle to send a notification message on finish\n"); -#endif - pc_printf(" -h show included file paths\n"); - pc_printf(" -i path for include files\n"); - pc_printf(" -l create list file (preprocess only)\n"); - pc_printf(" -o set base name of (P-code) output file\n"); - pc_printf(" -O optimization level (default=-O%d)\n",pc_optimize); - pc_printf(" 0 no optimization\n"); -#if 0 /* not used for SourceMod */ - pc_printf(" 1 JIT-compatible optimizations only\n"); -#endif - pc_printf(" 2 full optimizations\n"); - pc_printf(" -p set name of \"prefix\" file\n"); -#if !defined SC_LIGHT - pc_printf(" -r[name] write cross reference report to console or to specified file\n"); -#endif - pc_printf(" -S stack/heap size in cells (default=%d)\n",(int)pc_stksize); - pc_printf(" -s skip lines from the input file\n"); - pc_printf(" -t TAB indent size (in character positions, default=%d)\n",sc_tabsize); - pc_printf(" -v verbosity level; 0=quiet, 1=normal, 2=verbose (default=%d)\n",verbosity); - pc_printf(" -w disable a specific warning by its number\n"); - pc_printf(" -E treat warnings as errors\n"); - pc_printf(" -X abstract machine size limit in bytes\n"); - pc_printf(" -XD abstract machine data/stack size limit in bytes\n"); - pc_printf(" -\\ use '\\' for escape characters\n"); - pc_printf(" -^ use '^' for escape characters\n"); - pc_printf(" -;[+/-] require a semicolon to end each statement (default=%c)\n", sc_needsemicolon ? '+' : '-'); -#if 0 /* not allowed in SourceMod */ - pc_printf(" -([+/-] require parantheses for function invocation (default=%c)\n", optproccall ? '-' : '+'); -#endif - pc_printf(" sym=val define constant \"sym\" with value \"val\"\n"); - pc_printf(" sym= define constant \"sym\" with value 0\n"); -#if defined __WIN32__ || defined _WIN32 || defined _Windows || defined __MSDOS__ - pc_printf("\nOptions may start with a dash or a slash; the options \"-d0\" and \"/d0\" are\n"); - pc_printf("equivalent.\n"); -#endif - pc_printf("\nOptions with a value may optionally separate the value from the option letter\n"); - pc_printf("with a colon (\":\") or an equal sign (\"=\"). That is, the options \"-d0\", \"-d=0\"\n"); - pc_printf("and \"-d:0\" are all equivalent.\n"); - } /* if */ - norun = 1; - longjmp(errbuf,3); /* user abort */ -} - -static void setconstants(void) -{ - int debug; - - assert(sc_status==statIDLE); - append_constval(&tagname_tab,"_",0,0);/* "untagged" */ - append_constval(&tagname_tab,"bool",1,0); - - pc_anytag = pc_addtag("any"); - pc_functag = pc_addtag_flags("Function", FIXEDTAG|FUNCTAG); - pc_tag_string = pc_addtag("String"); - sc_rationaltag = pc_addtag("Float"); - pc_tag_void = pc_addtag_flags("void", FIXEDTAG); - pc_tag_object = pc_addtag_flags("object", FIXEDTAG|OBJECTTAG); - pc_tag_bool = pc_addtag("bool"); - pc_tag_null_t = pc_addtag_flags("null_t", FIXEDTAG|OBJECTTAG); - pc_tag_nullfunc_t = pc_addtag_flags("nullfunc_t", FIXEDTAG|OBJECTTAG); - - add_constant("true",1,sGLOBAL,1); /* boolean flags */ - add_constant("false",0,sGLOBAL,1); - add_constant("EOS",0,sGLOBAL,0); /* End Of String, or '\0' */ - add_constant("INVALID_FUNCTION", -1, sGLOBAL, pc_tag_nullfunc_t); - add_constant("cellbits",32,sGLOBAL,0); -#if defined _I32_MAX - add_constant("cellmax",_I32_MAX,sGLOBAL,0); - add_constant("cellmin",_I32_MIN,sGLOBAL,0); -#else - add_constant("cellmax",LONG_MAX,sGLOBAL,0); - add_constant("cellmin",LONG_MIN,sGLOBAL,0); -#endif - add_constant("charbits",sCHARBITS,sGLOBAL,0); - add_constant("charmin",0,sGLOBAL,0); - add_constant("charmax",~(-1 << sCHARBITS) - 1,sGLOBAL,0); - add_constant("ucharmax",(1 << (sizeof(cell)-1)*8)-1,sGLOBAL,0); - - add_constant("__Pawn",VERSION_INT,sGLOBAL,0); - - debug=0; - if ((sc_debug & (sCHKBOUNDS | sSYMBOLIC))==(sCHKBOUNDS | sSYMBOLIC)) - debug=2; - else if ((sc_debug & sCHKBOUNDS)==sCHKBOUNDS) - debug=1; - add_constant("debug",debug,sGLOBAL,0); - - append_constval(&sc_automaton_tab,"",0,0); /* anonymous automaton */ -} - -static int getclassspec(int initialtok,int *fpublic,int *fstatic,int *fstock,int *fconst) -{ - int tok,err; - cell val; - char *str; - - assert(fconst!=NULL); - assert(fstock!=NULL); - assert(fstatic!=NULL); - assert(fpublic!=NULL); - *fconst=FALSE; - *fstock=FALSE; - *fstatic=FALSE; - *fpublic=FALSE; - switch (initialtok) { - case tCONST: - *fconst=TRUE; - break; - case tSTOCK: - *fstock=TRUE; - break; - case tSTATIC: - *fstatic=TRUE; - break; - case tPUBLIC: - *fpublic=TRUE; - break; - } /* switch */ - - err=0; - do { - tok=lex(&val,&str); /* read in (new) token */ - switch (tok) { - case tCONST: - if (*fconst) - err=42; /* invalid combination of class specifiers */ - *fconst=TRUE; - break; - case tSTOCK: - if (*fstock) - err=42; /* invalid combination of class specifiers */ - *fstock=TRUE; - break; - case tSTATIC: - if (*fstatic) - err=42; /* invalid combination of class specifiers */ - *fstatic=TRUE; - break; - case tPUBLIC: - if (*fpublic) - err=42; /* invalid combination of class specifiers */ - *fpublic=TRUE; - break; - default: - lexpush(); - tok=0; /* force break out of loop */ - } /* switch */ - } while (tok && err==0); - - /* extra checks */ - if (*fstatic && *fpublic) { - err=42; /* invalid combination of class specifiers */ - *fstatic=*fpublic=FALSE; - } /* if */ - - if (err) - error(err); - return err==0; -} - -static void dodecl(const token_t *tok) -{ - declinfo_t decl; - - if (tok->id == tNATIVE || tok->id == tFORWARD) { - parse_decl(&decl, DECLFLAG_MAYBE_FUNCTION); - funcstub(tok->id, &decl, NULL); - return; - } - - int fpublic = FALSE, fstock = FALSE, fstatic = FALSE, fconst = FALSE; - switch (tok->id) { - case tPUBLIC: - fpublic = TRUE; - break; - case tSTOCK: - fstock = TRUE; - if (matchtoken(tSTATIC)) - fstatic = TRUE; - break; - case tSTATIC: - fstatic = TRUE; - - // For compatibility, we must include this case. Though "stock" should - // come first. - if (matchtoken(tSTOCK)) - fstock = TRUE; - break; - } - - int flags = DECLFLAG_MAYBE_FUNCTION | DECLFLAG_VARIABLE | DECLFLAG_ENUMROOT; - if (tok->id == tNEW) - flags |= DECLFLAG_OLD; - - if (!parse_decl(&decl, flags)) { - // Error will have been reported earlier. Reset |decl| so we don't crash - // thinking tag -1 has every flag. - decl.type.tag = 0; - } - - // Hacky bag o' hints as to whether this is a variable decl. - bool probablyVariable = tok->id == tNEW || - decl.type.has_postdims || - !lexpeek('(') || - ((decl.type.usage & uCONST) == uCONST); - - if (!decl.opertok && probablyVariable) { - if (tok->id == tNEW && decl.type.is_new) - error(143); - if (decl.type.tag & STRUCTTAG) { - pstruct_t *pstruct = pstructs_find(pc_tagname(decl.type.tag)); - declstructvar(decl.name, fpublic, pstruct); - } else { - declglb(&decl, fpublic, fstatic, fstock); - } - } else { - if (!newfunc(&decl, NULL, fpublic, fstatic, fstock, NULL)) { - // Illegal function or declaration. Drop the line, reset literal queue. - error(10); - lexclr(TRUE); - litidx = 0; - } - } -} - -/* parse - process all input text - * - * At this level, only static declarations and function definitions are legal. - */ -static void parse(void) -{ - token_t tok; - - while (freading){ - switch (lextok(&tok)) { - case 0: - /* ignore zero's */ - break; - case tSYMBOL: -#if 0 - if (strcmp(tok.str, "class") == 0) { - domethodmap(Layout_Class); - break; - } -#endif - // Fallthrough. - case tINT: - case tOBJECT: - case tCHAR: - case tVOID: - case tLABEL: - lexpush(); - // Fallthrough. - case tNEW: - case tSTATIC: - case tPUBLIC: - case tSTOCK: - case tOPERATOR: - case tNATIVE: - case tFORWARD: - { - dodecl(&tok); - break; - } - case tFUNCTAG: - dofuncenum(FALSE); - break; - case tTYPEDEF: - dotypedef(); - break; - case tTYPESET: - dotypeset(); - break; - case tSTRUCT: - declstruct(); - break; - case tCONST: - decl_const(sGLOBAL); - break; - case tENUM: - decl_enum(sGLOBAL); - break; - case tFUNCENUM: - dofuncenum(TRUE); - break; - case tMETHODMAP: - domethodmap(Layout_MethodMap); - break; - case '}': - error(54); /* unmatched closing brace */ - break; - case '{': - error(55); /* start of function body without function header */ - break; - default: - if (freading) { - error(10); /* illegal function or declaration */ - lexclr(TRUE); /* drop the rest of the line */ - litidx=0; /* drop any literal arrays (strings) */ - } /* if */ - } /* switch */ - } /* while */ -} - -/* dumplits - * - * Dump the literal pool (strings etc.) - * - * Global references: litidx (referred to only) - */ -static void dumplits(void) -{ - int j,k; - - if (sc_status==statSKIP) - return; - - k=0; - while (k=litidx) - stgwrite("\n"); /* force a newline after 10 dumps */ - /* Note: stgwrite() buffers a line until it is complete. It recognizes - * the end of line as a sequence of "\n\0", so something like "\n\t" - * so should not be passed to stgwrite(). - */ - } /* while */ - } /* while */ -} - -/* dumpzero - * - * Dump zero's for default initial values - */ -static void dumpzero(int count) -{ - int i; - - if (sc_status==statSKIP || count<=0) - return; - assert(curseg==2); - defstorage(); - i=0; - while (count-- > 0) { - outval(0, FALSE); - i=(i+1) % 16; - stgwrite((i==0 || count==0) ? "\n" : " "); - if (i==0 && count>0) - defstorage(); - } /* while */ -} - -static void aligndata(int numbytes) -{ - assert(numbytes % sizeof(cell) == 0); /* alignment must be a multiple of - * the cell size */ - assert(numbytes!=0); - - if ((((glb_declared+litidx)*sizeof(cell)) % numbytes)!=0) { - while ((((glb_declared+litidx)*sizeof(cell)) % numbytes)!=0) - litadd(0); - } /* if */ - -} - -#if !defined SC_LIGHT -/* sc_attachdocumentation() - * appends documentation comments to the passed-in symbol, or to a global - * string if "sym" is NULL. - */ -void sc_attachdocumentation(symbol *sym) -{ - int line; - size_t length; - char *str,*doc; - - if (!sc_makereport || sc_status!=statFIRST || sc_parsenum>0) { - /* just clear the entire table */ - delete_docstringtable(); - return; - } /* if */ - /* in the case of state functions, multiple documentation sections may - * appear; we should concatenate these - * (with forward declarations, this is also already the case, so the assertion - * below is invalid) - */ - // assert(sym==NULL || sym->documentation==NULL || sym->states!=NULL); - - /* first check the size */ - length=0; - for (line=0; (str=get_docstring(line))!=NULL && *str!=sDOCSEP; line++) { - if (length>0) - length++; /* count 1 extra for a separating space */ - length+=strlen(str); - } /* for */ - if (sym==NULL && sc_documentation!=NULL) { - length += strlen(sc_documentation) + 1 + 4; /* plus 4 for "

" */ - assert(length>strlen(sc_documentation)); - } /* if */ - - if (length>0) { - /* allocate memory for the documentation */ - if (sym!=NULL && sym->documentation!=NULL) - length+=strlen(sym->documentation) + 1 + 4;/* plus 4 for "

" */ - doc=(char*)malloc((length+1)*sizeof(char)); - if (doc!=NULL) { - /* initialize string or concatenate */ - if (sym==NULL && sc_documentation!=NULL) { - strcpy(doc,sc_documentation); - strcat(doc,"

"); - } else if (sym!=NULL && sym->documentation!=NULL) { - strcpy(doc,sym->documentation); - strcat(doc,"

"); - free(sym->documentation); - sym->documentation=NULL; - } else { - doc[0]='\0'; - } /* if */ - /* collect all documentation */ - while ((str=get_docstring(0))!=NULL && *str!=sDOCSEP) { - if (doc[0]!='\0') - strcat(doc," "); - strcat(doc,str); - delete_docstring(0); - } /* while */ - if (str!=NULL) { - /* also delete the separator */ - assert(*str==sDOCSEP); - delete_docstring(0); - } /* if */ - if (sym!=NULL) { - assert(sym->documentation==NULL); - sym->documentation=doc; - } else { - if (sc_documentation!=NULL) - free(sc_documentation); - sc_documentation=doc; - } /* if */ - } /* if */ - } else { - /* delete an empty separator, if present */ - if ((str=get_docstring(0))!=NULL && *str==sDOCSEP) - delete_docstring(0); - } /* if */ -} - -static void insert_docstring_separator(void) -{ - char sep[2]={sDOCSEP,'\0'}; - insert_docstring(sep); -} -#else - #define sc_attachdocumentation(s) (void)(s) - #define insert_docstring_separator() -#endif - -/* declstruct - declare global struct symbols - * - * global references: glb_declared (altered) - */ -static void declstructvar(char *firstname,int fpublic, pstruct_t *pstruct) -{ - char name[sNAMEMAX+1]; - int tok,i; - cell val; - char *str; - int cur_litidx = 0; - cell *values, *found; - int usage; - symbol *mysym,*sym; - - strcpy(name, firstname); - - values = (cell *)malloc(pstruct->argcount * sizeof(cell)); - found = (cell *)malloc(pstruct->argcount * sizeof(cell)); - - memset(found, 0, sizeof(cell) * pstruct->argcount); - - //:TODO: Make this work with stock - - /** - * Lastly, very lastly, we will insert a copy of this variable. - * This is soley to expose the pubvar. - */ - usage = uREAD|uCONST|uSTRUCT; - if (fpublic) - usage |= uPUBLIC; - mysym = NULL; - for (sym=glbtab.next; sym!=NULL; sym=sym->next) { - if (strcmp(name, sym->name) == 0) { - if ((sym->usage & uSTRUCT) && sym->vclass == sGLOBAL) { - if (sym->usage & uDEFINE) { - error(21, name); - } else { - if (sym->usage & uPUBLIC && !fpublic) - error(42); - } - } else { - error(21, name); - } - mysym = sym; - break; - } - } - if (!mysym) - mysym=addsym(name, 0, iVARIABLE, sGLOBAL, pc_addtag(pstruct->name), usage); - - if (!matchtoken('=')) { - matchtoken(';'); - /* Mark it as undefined instead */ - mysym->usage = uSTOCK|uSTRUCT; - free(found); - free(values); - return; - } - - mysym->usage = usage; - needtoken('{'); - - do { - structarg_t *arg; - /* Detect early exit */ - if (matchtoken('}')) { - lexpush(); - break; - } - tok=lex(&val,&str); - if (tok != tSYMBOL) { - error(1, "-identifier-", str); - continue; - } - arg=pstructs_getarg(pstruct,str); - if (arg == NULL) - error(96, str, sym->name); - needtoken('='); - cur_litidx = litidx; - tok=lex(&val,&str); - if (!arg) { - continue; - } - if (tok == tSTRING) { - assert(litidx != 0); - if (arg->dimcount != 1) - { - error(48); - } else if (arg->tag != pc_tag_string) { - error(213); - } - values[arg->index] = glb_declared * sizeof(cell); - glb_declared += (litidx-cur_litidx); - found[arg->index] = 1; - } else if (tok == tNUMBER || tok == tRATIONAL) { - /* eat optional 'f' */ - matchtoken('f'); - if (arg->ident != iVARIABLE && arg->ident != iREFERENCE) { - error(23); - } else { - if ((arg->tag == pc_addtag("Float") && tok == tNUMBER) || - (arg->tag == 0 && tok == tRATIONAL)) - { - error(213); - } - if (arg->ident == iVARIABLE) { - values[arg->index] = val; - } else if (arg->ident == iREFERENCE) { - values[arg->index] = glb_declared * sizeof(cell); - glb_declared += 1; - litadd(val); - cur_litidx = litidx; - } - found[arg->index] = 1; - } - } else if (tok == tSYMBOL) { - for (sym=glbtab.next; sym!=NULL; sym=sym->next) { - if (sym->vclass != sGLOBAL) - continue; - if (strcmp(sym->name, str) == 0) { - if (arg->ident == iREFERENCE && sym->ident != iVARIABLE) { - error(97, str); - } else if (arg->ident == iARRAY) { - if (sym->ident != iARRAY) { - error(97, str); - } else { - /* :TODO: We should check dimension sizes here... */ - } - } else if (arg->ident == iREFARRAY) { - if (sym->ident != iARRAY) - error(97, str); - /* :TODO: Check dimension sizes! */ - } else { - error(97, str); - } - if (sym->tag != arg->tag) - error(213); - sym->usage |= uREAD; - values[arg->index] = sym->addr; - found[arg->index] = 1; - refer_symbol(sym, mysym); - break; - } - } - if (!sym) - error(17, str); - } else { - error(1, "-identifier-", str); - } - } while (matchtoken(',')); - needtoken('}'); - matchtoken(';'); /* eat up optional semicolon */ - - for (i=0; iargcount; i++) { - if (!found[i]) { - structarg_t *arg = pstruct->args[i]; - if (arg->ident == iREFARRAY) { - values[arg->index] = glb_declared * sizeof(cell); - glb_declared += 1; - litadd(0); - cur_litidx = litidx; - } else if (arg->ident == iVARIABLE) { - values[arg->index] = 0; - } else { - /* :TODO: broken for iARRAY! (unused tho) */ - } - } - } - - mysym->addr = glb_declared * sizeof(cell); - glb_declared += pstruct->argcount; - - for (i=0; iargcount; i++) - litadd(values[i]); - - begdseg(); - dumplits(); - litidx=0; - - free(found); - free(values); -} - -/* declglb - declare global symbols - * - * Declare a static (global) variable. Global variables are stored in - * the DATA segment. - * - * global references: glb_declared (altered) - */ -static void declglb(declinfo_t *decl,int fpublic,int fstatic,int fstock) -{ - int ispublic; - cell cidx; - ucell address; - int glb_incr; - int slength=0; - short filenum; - symbol *sym; -#if !defined NDEBUG - cell glbdecl=0; -#endif - declinfo_t orig_decl = *decl; - - assert(!fpublic || !fstatic); /* may not both be set */ - insert_docstring_separator(); /* see comment in newfunc() */ - filenum=fcurrent; /* save file number at the start of the declaration */ - - for (;;) { - typeinfo_t *type = &decl->type; - - check_void_decl(decl, TRUE); - - ispublic=fpublic; - if (decl->name[0]==PUBLIC_CHAR) { - ispublic=TRUE; /* implicitly public variable */ - assert(!fstatic); - } - slength = fix_char_size(decl); - assert(sc_curstates==0); - sc_curstates=getstates(decl->name); - if (sc_curstates<0) { - error(85,decl->name); /* empty state list on declaration */ - sc_curstates=0; - } else if (sc_curstates>0 && ispublic) { - error(88,decl->name); /* public variables may not have states */ - sc_curstates=0; - } /* if */ - sym=findconst(decl->name,NULL); - if (sym==NULL) { - sym=findglb(decl->name,sSTATEVAR); - /* if a global variable without states is found and this declaration has - * states, the declaration is okay - */ - if (sym!=NULL && sym->states==NULL && sc_curstates>0) - sym=NULL; /* set to NULL, we found the global variable */ - if (sc_curstates>0 && findglb(decl->name,sGLOBAL)!=NULL) - error(233,decl->name); /* state variable shadows a global variable */ - } /* if */ - /* we have either: - * a) not found a matching variable (or rejected it, because it was a shadow) - * b) found a global variable and we were looking for that global variable - * c) found a state variable in the automaton that we were looking for - */ - assert(sym==NULL - || (sym->states==NULL && sc_curstates==0) - || (sym->states!=NULL && sym->next!=NULL && sym->states->next->index==sc_curstates)); - /* a state variable may only have a single id in its list (so either this - * variable has no states, or it has a single list) - */ - assert(sym==NULL || sym->states==NULL || sym->states->next->next==NULL); - /* it is okay for the (global) variable to exist, as long as it belongs to - * a different automaton - */ - if (sym!=NULL && (sym->usage & uDEFINE)!=0) - error(21,decl->name); /* symbol already defined */ - /* if this variable is never used (which can be detected only in the - * second stage), shut off code generation - */ - cidx=0; /* only to avoid a compiler warning */ - if (sc_status==statWRITE && sym!=NULL && (sym->usage & (uREAD | uWRITTEN))==0) { - sc_status=statSKIP; - cidx=code_idx; - #if !defined NDEBUG - glbdecl=glb_declared; - #endif - } /* if */ - begdseg(); /* real (initialized) data in data segment */ - assert(litidx==0); /* literal queue should be empty */ - if (sc_alignnext) { - litidx=0; - aligndata(sc_dataalign); - dumplits(); /* dump the literal queue */ - sc_alignnext=FALSE; - litidx=0; /* global initial data is dumped, so restart at zero */ - } /* if */ - assert(litidx==0); /* literal queue should be empty (again) */ - if (type->ident == iREFARRAY) { - // Dynamc array in global scope. - assert(type->is_new); - error(162); - } - initials3(decl); - if (type->tag == pc_tag_string && type->numdim == 1 && !type->dim[type->numdim - 1]) { - slength = glbstringread; - } - assert(type->size>=litidx); - if (type->numdim == 1) - type->dim[0] = (int)type->size; - address=sizeof(cell)*glb_declared; - glb_incr=(int)type->size; - if (type->size != CELL_MAX && address==sizeof(cell)*glb_declared) { - dumplits(); /* dump the literal queue */ - dumpzero((int)(type->size)-litidx); - } /* if */ - litidx=0; - if (sym==NULL) { /* define only if not yet defined */ - sym=addvariable3(decl,address,sGLOBAL,slength); - } else { /* if declared but not yet defined, adjust the variable's address */ - assert((sym->states==NULL && sc_curstates==0) - || (sym->states->next!=NULL && sym->states->next->index==sc_curstates && sym->states->next->next==NULL)); - sym->addr=address; - sym->codeaddr=code_idx; - sym->usage|=uDEFINE; - } /* if */ - assert(sym!=NULL); - sc_curstates=0; - if (ispublic) - sym->usage|=uPUBLIC|uREAD; - if (decl->type.usage & uCONST) - sym->usage|=uCONST; - if (fstock) - sym->usage|=uSTOCK; - if (fstatic) - sym->fnumber=filenum; - sc_attachdocumentation(sym);/* attach any documenation to the variable */ - if (sc_status==statSKIP) { - sc_status=statWRITE; - code_idx=cidx; - assert(glb_declared==glbdecl); - } else { - glb_declared+=glb_incr; /* add total number of cells (if added to the end) */ - } /* if */ - - if (!matchtoken(',')) - break; - - if (decl->type.is_new) - reparse_new_decl(decl, DECLFLAG_VARIABLE|DECLFLAG_ENUMROOT); - else - reparse_old_decl(decl, DECLFLAG_VARIABLE|DECLFLAG_ENUMROOT); - }; - needtoken(tTERM); /* if not comma, must be semicolumn */ -} - -static bool parse_local_array_initializer(typeinfo_t *type, int *curlit, int *slength) -{ - if (sc_alignnext) { - aligndata(sc_dataalign); - sc_alignnext=FALSE; - } /* if */ - *curlit = litidx; /* save current index in the literal table */ - if (type->numdim && !type->dim[type->numdim-1]) - type->size = 0; - initials(type->ident,type->tag,&type->size,type->dim,type->numdim,type->enumroot); - if (type->tag == pc_tag_string && type->numdim == 1 && !type->dim[type->numdim - 1]) - *slength = glbstringread; - if (type->size == 0) - return false; - if (type->numdim == 1) - type->dim[0] = type->size; - return true; -} - -/* declloc - declare local symbols - * - * Declare local (automatic) variables. Since these variables are relative - * to the STACK, there is no switch to the DATA segment. These variables - * cannot be initialized either. - * - * global references: declared (altered) - * funcstatus (referred to only) - */ -static void declloc(int tokid) -{ - symbol *sym; - value lval = {0}; - int cur_lit=0; - int staging_start; - int slength = 0; - int fstatic = (tokid == tSTATIC); - declinfo_t decl; - - int declflags = DECLFLAG_VARIABLE | DECLFLAG_ENUMROOT | DECLFLAG_DYNAMIC_ARRAYS; - if (tokid == tNEW || tokid == tDECL) - declflags |= DECLFLAG_OLD; - else if (tokid == tNEWDECL) - declflags |= DECLFLAG_NEW; - - parse_decl(&decl, declflags); - - for (;;) { - typeinfo_t *type = &decl.type; - - slength=0; - - if (decl.name[0]==PUBLIC_CHAR) - error(56, decl.name); /* local variables cannot be public */ - - /* Note: block locals may be named identical to locals at higher - * compound blocks (as with standard C); so we must check (and add) - * the "nesting level" of local variables to verify the - * multi-definition of symbols. - */ - if ((sym=findloc(decl.name))!=NULL && sym->compound==nestlevel) - error(21, decl.name); /* symbol already defined */ - - /* Although valid, a local variable whose name is equal to that - * of a global variable or to that of a local variable at a lower - * level might indicate a bug. - */ - if (((sym=findloc(decl.name)) != NULL && sym->compound != nestlevel) || - findglb(decl.name,sGLOBAL) != NULL) - { - error(219, decl.name); /* variable shadows another symbol */ - } - - slength = fix_char_size(&decl); - - if (fstatic && type->ident == iREFARRAY) - error(165); - - if (type->ident == iARRAY || fstatic) { - if (!parse_local_array_initializer(type, &cur_lit, &slength)) - return; - } - /* reserve memory (on the stack) for the variable */ - if (fstatic) { - /* write zeros for uninitialized fields */ - while (litidx < cur_lit + type->size) - litadd(0); - sym=addvariable2(decl.name,(cur_lit+glb_declared)*sizeof(cell),type->ident,sSTATIC, - type->tag,type->dim,type->numdim,type->idxtag,slength); - } else if (type->ident!=iREFARRAY) { - declared+=type->size; /* variables are put on stack, adjust "declared" */ - sym=addvariable2(decl.name,-declared*sizeof(cell),type->ident,sLOCAL,type->tag, - type->dim,type->numdim,type->idxtag,slength); - if (type->ident == iVARIABLE) { - assert(!staging); - stgset(TRUE); /* start stage-buffering */ - assert(stgidx==0); - staging_start=stgidx; - } /* if */ - markexpr(sLDECL,decl.name,-declared*sizeof(cell)); /* mark for better optimization */ - modstk(-type->size * sizeof(cell)); - markstack(MEMUSE_STATIC, type->size); - assert(curfunc!=NULL); - assert((curfunc->usage & uNATIVE)==0); - if (curfunc->x.stacksizex.stacksize=declared+1; /* +1 for PROC opcode */ - } else if (type->ident == iREFARRAY) { - // Generate the symbol so we can access its stack address during initialization. - declared+=1; /* one cell for address */ - sym=addvariable(decl.name,-declared*sizeof(cell),type->ident,sLOCAL,type->tag,type->dim,type->numdim,type->idxtag); - - // If we're new-style, a REFARRAY indicates prefix brackets. We need to - // be initialized since we don't support fully dynamic arrays yet; i.e., - // "int[] x;" doesn't have any sensible semantics. There are two - // acceptable initialization sequences: "new " and a string - // literal. In other cases (such as a fixed-array literal), we error. - // - // For now, we only implement the string literal initializer. - if (type->is_new && needtoken('=')) { - if (type->isCharArray() && !lexpeek(tNEW)) { - // Error if we're assigning something other than a string literal. - needtoken(tSTRING); - - // Note: the genarray call pushes the result array into the stack - // slot of our local variable - we can access |sym| after. - // - // push.c N - // genarray 1 - // const.pri DAT + offset - // load.s.alt sym->addr - // movs N * sizeof(cell) - int cells = litidx - cur_lit; - pushval(cells); - genarray(1, false); - ldconst((cur_lit + glb_declared) * sizeof(cell), sPRI); - copyarray(sym, cells * sizeof(cell)); - } else if (matchtoken(tNEW)) { - int tag = 0; - if (parse_new_typename(NULL, &tag)) { - if (tag != type->tag) - error(164, pc_typename(tag), pc_typename(type->tag)); - } - - for (int i = 0; i < type->numdim; i++) { - if (!needtoken('[')) - break; - - value val; - symbol *child; - int ident = doexpr2( - TRUE, FALSE, TRUE, FALSE, - &type->idxtag[i], - &child, 0, &val); - if (i == type->numdim - 1 && type->tag == pc_tag_string) - stradjust(sPRI); - pushreg(sPRI); - - switch (ident) { - case iVARIABLE: - case iEXPRESSION: - case iARRAYCELL: - case iCONSTEXPR: - break; - default: - error(29); - break; - } - - if (!needtoken(']')) - break; - } - - genarray(type->numdim, true); - } else if (lexpeek('{')) { - // Dynamic array with fixed initializer. - error(160); - - // Parse just to clear the tokens. First give '=' back. - lexpush(); - if (!parse_local_array_initializer(type, &cur_lit, &slength)) - return; - } else { - // Give the '=' back so we error later. - lexpush(); - } - } - - /* genarray() pushes the address onto the stack, so we don't need to call modstk() here! */ - markheap(MEMUSE_DYNAMIC, 0); - markstack(MEMUSE_STATIC, 1); - assert(curfunc != NULL && ((curfunc->usage & uNATIVE) == 0)); - if (curfunc->x.stacksizex.stacksize=declared+1; /* +1 for PROC opcode */ - } /* if */ - /* now that we have reserved memory for the variable, we can proceed - * to initialize it */ - assert(sym!=NULL); /* we declared it, it must be there */ - sym->compound=nestlevel; /* for multiple declaration/shadowing check */ - if (type->usage & uCONST) - sym->usage|=uCONST; - if (!fstatic) { /* static variables already initialized */ - if (type->ident == iVARIABLE) { - /* simple variable, also supports initialization */ - int ctag = type->tag; /* set to "tag" by default */ - int explicit_init=FALSE;/* is the variable explicitly initialized? */ - int cident = type->ident; - if (matchtoken('=')) { - if (!autozero) - error(10); - cident=doexpr(FALSE,FALSE,FALSE,FALSE,&ctag,NULL,TRUE); - explicit_init=TRUE; - } else { - if (autozero) - ldconst(0,sPRI); /* uninitialized variable, set to zero */ - } /* if */ - if (autozero) { - /* now try to save the value (still in PRI) in the variable */ - lval.sym=sym; - lval.ident=iVARIABLE; - lval.constval=0; - lval.tag=type->tag; - check_userop(NULL,ctag,lval.tag,2,NULL,&ctag); - store(&lval); - markexpr(sEXPR,NULL,0); /* full expression ends after the store */ - } - assert(staging); /* end staging phase (optimize expression) */ - stgout(staging_start); - stgset(FALSE); - if (!matchtag_string(cident, ctag)) - matchtag(type->tag,ctag,TRUE); - /* if the variable was not explicitly initialized, reset the - * "uWRITTEN" flag that store() set */ - if (!explicit_init) - sym->usage &= ~uWRITTEN; - } else if (type->ident != iREFARRAY) { - /* an array */ - assert(cur_lit>=0 && cur_lit<=litidx && litidx<=litmax); - assert(type->size > 0 && type->size >= sym->dim.array.length); - assert(type->numdim > 1 || type->size == sym->dim.array.length); - if (autozero) { - /* final literal values that are zero make no sense to put in the literal - * pool, because values get zero-initialized anyway; we check for this, - * because users often explicitly initialize strings to "" - */ - while (litidx>cur_lit && litq[litidx-1]==0) - litidx--; - /* if the array is not completely filled, set all values to zero first */ - if (litidx - cur_lit < type->size && (ucell)type->size < CELL_MAX) - fillarray(sym, type->size * sizeof(cell), 0); - } - if (cur_lit=0 && cur<=numdim); - if (cur==numdim) - return 0; - subsize=calc_arraysize(dim,numdim,cur+1); - newsize=dim[cur]+dim[cur]*subsize; - if ((ucell)subsize>=CELL_MAX || newsize>=CELL_MAX || newsize*sizeof(cell)>=CELL_MAX) - return CELL_MAX; - return newsize; -} - -static cell gen_indirection_vecs(array_info_t *ar, int dim, cell cur_offs) -{ - int i; - cell write_offs = cur_offs; - cell *data_offs = ar->data_offs; - - cur_offs += ar->dim_list[dim]; - - /** - * Dimension n-x where x > 2 will have sub-vectors. - * Otherwise, we just need to reference the data section. - */ - if (ar->dim_count > 2 && dim < ar->dim_count - 2) - { - /** - * For each index at this dimension, write offstes to our sub-vectors. - * After we write one sub-vector, we generate its sub-vectors recursively. - * At the end, we're given the next offset we can use. - */ - for (i = 0; i < ar->dim_list[dim]; i++) - { - ar->base[write_offs] = (cur_offs - write_offs) * sizeof(cell); - write_offs++; - ar->cur_dims[dim] = i; - cur_offs = gen_indirection_vecs(ar, dim + 1, cur_offs); - } - } else if (ar->dim_count > 1) { - /** - * In this section, there are no sub-vectors, we need to write offsets - * to the data. This is separate so the data stays in one big chunk. - * The data offset will increment by the size of the last dimension, - * because that is where the data is finally computed as. But the last - * dimension can be of variable size, so we have to detect that. - */ - if (ar->dim_list[dim + 1] == 0) - { - int vec_start = 0; - - /** - * Using the precalculated offsets, compute an index into the last - * dimension array. - */ - for (i = 0; i < dim; i++) - { - vec_start += ar->cur_dims[i] * ar->dim_offs_precalc[i]; - } - - /** - * Now, vec_start points to a vector of last dimension offsets for - * the preceding dimension combination(s). - * I.e. (1,2,i,j) in [3][4][5][] will be: - * j = 1*(4*5) + 2*(5) + i, and the parenthetical expressions are - * precalculated for us so we can easily generalize here. - */ - for (i = 0; i < ar->dim_list[dim]; i++) - { - ar->base[write_offs] = (*data_offs - write_offs) * sizeof(cell); - write_offs++; - *data_offs = *data_offs + ar->lastdim_list[vec_start + i]; - } - } else { - /** - * The last dimension size is constant. There's no extra work to - * compute the last dimension size. - */ - for (i = 0; i < ar->dim_list[dim]; i++) - { - ar->base[write_offs] = (*data_offs - write_offs) * sizeof(cell); - write_offs++; - *data_offs = *data_offs + ar->dim_list[dim + 1]; - } - } - } - - return cur_offs; -} - -static cell calc_indirection(const int dim_list[], int dim_count, int dim) -{ - cell size = dim_list[dim]; - - if (dim < dim_count - 2) - { - size += dim_list[dim] * calc_indirection(dim_list, dim_count, dim + 1); - } - - return size; -} - -static void adjust_indirectiontables(int dim[],int numdim,int cur,cell increment, - int startlit,constvalue *lastdim,int *skipdim) -{ - /* Find how many cells the indirection table will be */ - cell tbl_size; - int *dyn_list = NULL; - int cur_dims[sDIMEN_MAX]; - cell dim_offset_precalc[sDIMEN_MAX]; - array_info_t ar; - - if (numdim == 1) - { - return; - } - - tbl_size = calc_indirection(dim, numdim, 0); - memset(cur_dims, 0, sizeof(cur_dims)); - - /** - * Flatten the last dimension array list -- this makes - * things MUCH easier in the indirection calculator. - */ - if (lastdim) - { - int i; - constvalue *ld = lastdim->next; - - /* Get the total number of last dimensions. */ - for (i = 0; ld != NULL; i++, ld = ld->next) - { - /* Nothing */ - } - /* Store them in an array instead of a linked list. */ - dyn_list = (int *)malloc(sizeof(int) * i); - for (i = 0, ld = lastdim->next; - ld != NULL; - i++, ld = ld->next) - { - dyn_list[i] = ld->value; - } - - /** - * Pre-calculate all of the offsets. This speeds up and simplifies - * the indirection process. For example, if we have an array like: - * [a][b][c][d][], and given (A,B,C), we want to find the size of - * the last dimension [A][B][C][i], we must do: - * - * list[A*(b*c*d) + B*(c*d) + C*(d) + i] - * - * Generalizing this algorithm in the indirection process is expensive, - * so we lessen the need for nested loops by pre-computing the parts: - * (b*c*d), (c*d), and (d). - * - * In other words, finding the offset to dimension N at index I is - * I * (S[N+1] * S[N+2] ... S[N+n-1]) where S[] is the size of dimension - * function, and n is the index of the last dimension. - */ - for (i = 0; i < numdim - 1; i++) - { - int j; - - dim_offset_precalc[i] = 1; - for (j = i + 1; j < numdim - 1; j++) - { - dim_offset_precalc[i] *= dim[j]; - } - } - - ar.dim_offs_precalc = dim_offset_precalc; - ar.lastdim_list = dyn_list; - } else { - ar.dim_offs_precalc = NULL; - ar.lastdim_list = NULL; - } - - ar.base = &litq[startlit]; - ar.data_offs = &tbl_size; - ar.dim_list = dim; - ar.dim_count = numdim; - ar.cur_dims = cur_dims; - - gen_indirection_vecs(&ar, 0, 0); - - free(dyn_list); -} - -/* initials - * - * Initialize global objects and local arrays. - * size==array cells (count), if 0 on input, the routine counts the number of elements - * tag==required tagname id (not the returned tag) - * - * Global references: litidx (altered) - */ -static void initials2(int ident,int tag,cell *size,int dim[],int numdim, - constvalue *enumroot, int eq_match_override, int curlit_override) -{ - int ctag; - cell tablesize; - int curlit=(curlit_override == -1) ? litidx : curlit_override; - int err=0; - - if (eq_match_override == -1) { - eq_match_override = matchtoken('='); - } - - if (numdim > 2) { - int d, hasEmpty = 0; - for (d = 0; d < numdim; d++) { - if (dim[d] == 0) - hasEmpty++; - } - /* Work around ambug 4977 where indirection vectors are computed wrong. */ - if (hasEmpty && hasEmpty < numdim-1 && dim[numdim-1]) { - error(101); - /* This will assert with something like [2][][256] from a separate bug. - * To prevent this assert, automatically wipe the rest of the dims. - */ - for (d = 0; d < numdim - 1; d++) - dim[d] = 0; - } - } - - if (!eq_match_override) { - assert(ident!=iARRAY || numdim>0); - if (ident==iARRAY && dim[numdim-1]==0) { - /* declared as "myvar[];" which is senseless (note: this *does* make - * sense in the case of a iREFARRAY, which is a function parameter) - */ - error(9); /* array has zero length -> invalid size */ - } /* if */ - if (ident==iARRAY) { - assert(numdim>0 && numdim<=sDIMEN_MAX); - *size=calc_arraysize(dim,numdim,0); - if (*size==(cell)CELL_MAX) { - error(9); /* array is too big -> invalid size */ - return; - } /* if */ - /* first reserve space for the indirection vectors of the array, then - * adjust it to contain the proper values - * (do not use dumpzero(), as it bypasses the literal queue) - */ - for (tablesize=calc_arraysize(dim,numdim-1,0); tablesize>0; tablesize--) - litadd(0); - if (dim[numdim-1]!=0) /* error 9 has already been given */ - adjust_indirectiontables(dim,numdim,0,0,curlit,NULL,NULL); - } /* if */ - return; - } /* if */ - - if (ident==iVARIABLE) { - assert(*size==1); - init(ident,&ctag,NULL); - matchtag(tag,ctag,TRUE); - } else { - assert(numdim>0); - if (numdim==1) { - *size=initvector(ident,tag,dim[0],FALSE,enumroot,NULL); - } else { - int errorfound=FALSE; - int counteddim[sDIMEN_MAX]; - int idx; - constvalue lastdim={NULL,"",0,0}; /* sizes of the final dimension */ - int skipdim=0; - - if (dim[numdim-1]!=0) - *size=calc_arraysize(dim,numdim,0); /* calc. full size, if known */ - /* already reserve space for the indirection tables (for an array with - * known dimensions) - * (do not use dumpzero(), as it bypasses the literal queue) - */ - for (tablesize=calc_arraysize(dim,numdim-1,0); tablesize>0; tablesize--) - litadd(0); - /* now initialize the sub-arrays */ - memset(counteddim,0,sizeof counteddim); - initarray(ident,tag,dim,numdim,0,curlit,counteddim,&lastdim,enumroot,&errorfound); - /* check the specified array dimensions with the initializer counts */ - for (idx=0; idxdim[idx]) { - error(18); /* initialization data exceeds declared size */ - err++; - } /* if */ - } /* for */ - if (numdim>1 && dim[numdim-1]==0) { - /* also look whether, by any chance, all "counted" final dimensions are - * the same value; if so, we can store this - */ - constvalue *ld=lastdim.next; - int d,match; - for (d=0; dname,NULL,16)==d); - if (d==0) - match=ld->value; - else if (match!=ld->value) - break; - ld=ld->next; - } /* for */ - if (d==dim[numdim-2]) - dim[numdim-1]=match; - } /* if */ - /* after all arrays have been initalized, we know the (major) dimensions - * of the array and we can properly adjust the indirection vectors - */ - if (err==0) - adjust_indirectiontables(dim,numdim,0,0,curlit,&lastdim,&skipdim); - delete_consttable(&lastdim); /* clear list of minor dimension sizes */ - } /* if */ - } /* if */ - - if (*size==0) - *size=litidx-curlit; /* number of elements defined */ -} - -static void initials(int ident,int tag,cell *size,int dim[],int numdim, - constvalue *enumroot) -{ - initials2(ident, tag, size, dim, numdim, enumroot, -1, -1); -} - -static void initials3(declinfo_t *decl) -{ - typeinfo_t *type = &decl->type; - initials(type->ident, type->tag, &type->size, type->dim, type->numdim, type->enumroot); -} - -static cell initarray(int ident,int tag,int dim[],int numdim,int cur, - int startlit,int counteddim[],constvalue *lastdim, - constvalue *enumroot,int *errorfound) -{ - cell dsize,totalsize; - int idx,abortparse; - - assert(cur>=0 && cur=0); - assert(cur+2<=numdim);/* there must be 2 dimensions or more to do */ - assert(errorfound!=NULL && *errorfound==FALSE); - totalsize=0; - needtoken('{'); - for (idx=0,abortparse=FALSE; !abortparse; idx++) { - - /* In case the major dimension is zero, we need to store the offset - * to the newly detected sub-array into the indirection table; i.e. - * this table needs to be expanded and updated. - * In the current design, the indirection vectors for a multi-dimensional - * array are adjusted after parsing all initializers. Hence, it is only - * necessary at this point to reserve space for an extra cell in the - * indirection vector. - */ - if (dim[cur]==0) { - litinsert(0,startlit); - } else if (idx>=dim[cur]) { - error(18); /* initialization data exceeds array size */ - break; - } /* if */ - if (cur+20) { - if (idxcounteddim[cur]) - error(18); /* initialization data exceeds declared size */ - } /* if */ - counteddim[cur]=idx; - - return totalsize+dim[cur]; /* size of sub-arrays + indirection vector */ -} - -/* initvector - * Initialize a single dimensional array - */ -static cell initvector(int ident,int tag,cell size,int fillzero, - constvalue *enumroot,int *errorfound) -{ - cell prev1=0,prev2=0; - int ellips=FALSE; - int curlit=litidx; - int rtag,ctag; - - assert(ident==iARRAY || ident==iREFARRAY); - if (matchtoken('{')) { - constvalue *enumfield=(enumroot!=NULL) ? enumroot->next : NULL; - do { - int fieldlit=litidx; - int matchbrace,i; - if (matchtoken('}')) { /* to allow for trailing ',' after the initialization */ - lexpush(); - break; - } /* if */ - if ((ellips=matchtoken(tELLIPS))!=0) - break; - /* for enumeration fields, allow another level of braces ("{...}") */ - matchbrace=0; /* preset */ - ellips=0; - if (enumfield!=NULL) - matchbrace=matchtoken('{'); - for ( ;; ) { - prev2=prev1; - prev1=init(ident,&ctag,errorfound); - if (!matchbrace) - break; - if ((ellips=matchtoken(tELLIPS))!=0) - break; - if (!matchtoken(',')) { - needtoken('}'); - break; - } /* for */ - } /* for */ - /* if this array is based on an enumeration, fill the "field" up with - * zeros, and toggle the tag - */ - if (enumroot!=NULL && enumfield==NULL) - error(227); /* more initializers than enum fields */ - rtag=tag; /* preset, may be overridden by enum field tag */ - if (enumfield!=NULL) { - cell step; - int cmptag=enumfield->index; - symbol *symfield=findconst(enumfield->name,&cmptag); - if (cmptag>1) - error(91,enumfield->name); /* ambiguous constant, needs tag override */ - assert(symfield!=NULL); - assert(fieldlitsymfield->dim.array.length) - error(228); /* length of initializer exceeds size of the enum field */ - if (ellips) { - step=prev1-prev2; - } else { - step=0; - prev1=0; - } /* if */ - for (i=litidx-fieldlit; idim.array.length; i++) { - prev1+=step; - litadd(prev1); - } /* for */ - rtag=symfield->x.tags.index; /* set the expected tag to the index tag */ - enumfield=enumfield->next; - } /* if */ - matchtag(rtag,ctag,TRUE); - } while (matchtoken(',')); /* do */ - needtoken('}'); - } else { - if (!lexpeek('}')) - { - init(ident,&ctag,errorfound); - matchtag(tag,ctag,TRUE); - } - } /* if */ - /* fill up the literal queue with a series */ - if (ellips) { - cell step=((litidx-curlit)==1) ? (cell)0 : prev1-prev2; - if (size==0 || (litidx-curlit)==0) - error(41); /* invalid ellipsis, array size unknown */ - else if ((litidx-curlit)==(int)size) - error(18); /* initialization data exceeds declared size */ - while ((litidx-curlit)<(int)size) { - prev1+=step; - litadd(prev1); - } /* while */ - } /* if */ - if (fillzero && size>0) { - while ((litidx-curlit)<(int)size) - litadd(0); - } /* if */ - if (size==0) { - size=litidx-curlit; /* number of elements defined */ - } else if (litidx-curlit>(int)size) { /* e.g. "myvar[3]={1,2,3,4};" */ - error(18); /* initialization data exceeds declared size */ - litidx=(int)size+curlit; /* avoid overflow in memory moves */ - } /* if */ - return size; -} - -/* init - * - * Evaluate one initializer. - */ -static cell init(int ident,int *tag,int *errorfound) -{ - cell i = 0; - - if (matchtoken(tSTRING)){ - /* lex() automatically stores strings in the literal table (and - * increases "litidx") */ - if (ident==iVARIABLE) { - error(6); /* must be assigned to an array */ - litidx=1; /* reset literal queue */ - } /* if */ - *tag=pc_tag_string; - } else if (exprconst(&i,tag,NULL)){ - litadd(i); /* store expression result in literal table */ - } else { - if (errorfound!=NULL) - *errorfound=TRUE; - } /* if */ - return i; -} - -/* needsub - * - * Get required array size - */ -static cell needsub(int *tag,constvalue **enumroot) -{ - cell val; - symbol *sym; - - assert(tag!=NULL); - *tag=0; - if (enumroot!=NULL) - *enumroot=NULL; /* preset */ - if (matchtoken(']')) /* we have already seen "[" */ - return 0; /* zero size (like "char msg[]") */ - - exprconst(&val,tag,&sym); /* get value (must be constant expression) */ - if (val<0) { - error(9); /* negative array size is invalid; assumed zero */ - val=0; - } /* if */ - needtoken(']'); - - if (enumroot!=NULL) { - /* get the field list for an enumeration */ - assert(*enumroot==NULL);/* should have been preset */ - assert(sym==NULL || sym->ident==iCONSTEXPR); - if (sym!=NULL && (sym->usage & uENUMROOT)==uENUMROOT) { - assert(sym->dim.enumlist!=NULL); - *enumroot=sym->dim.enumlist; - } /* if */ - } /* if */ - - return val; /* return array size */ -} - -/* decl_const - declare a single constant - * - */ -static void decl_const(int vclass) -{ - char constname[sNAMEMAX+1]; - cell val; - token_t tok; - int exprtag; - int symbolline; - symbol *sym; - - insert_docstring_separator(); /* see comment in newfunc() */ - do { - int orgfline; - - // Since spcomp is terrible, it's hard to use parse_decl() here - there - // are all sorts of restrictions on const. We just implement some quick - // detection instead. - int tag = 0; - switch (lextok(&tok)) { - case tINT: - case tOBJECT: - case tCHAR: - tag = parse_new_typename(&tok); - break; - case tLABEL: - tag = pc_addtag(tok.str); - break; - case tSYMBOL: - // See if we can peek ahead another symbol. - if (lexpeek(tSYMBOL)) { - // This is a new-style declaration. - tag = parse_new_typename(&tok); - } else { - // Otherwise, we got "const X ..." so the tag is int. Give the - // symbol back to the lexer so we get it as the name. - lexpush(); - } - break; - default: - error(122); - break; - } - - if (expecttoken(tSYMBOL, &tok)) - strcpy(constname, tok.str); - else - strcpy(constname, "__unknown__"); - - symbolline=fline; /* save line where symbol was found */ - needtoken('='); - exprconst(&val,&exprtag,NULL); /* get value */ - - /* add_constant() checks for duplicate definitions */ - /* temporarily reset the line number to where the symbol was defined */ - orgfline=fline; - fline=symbolline; - matchtag(tag,exprtag,FALSE); - fline=orgfline; - - sym=add_constant(constname,val,vclass,tag); - if (sym!=NULL) - sc_attachdocumentation(sym);/* attach any documenation to the constant */ - } while (matchtoken(',')); /* enddo */ /* more? */ - needtoken(tTERM); -} - -static void check_struct_name(const char *name) -{ - LayoutSpec spec = deduce_layout_spec_by_name(name); - if (!can_redef_layout_spec(spec, Layout_PawnStruct)) - error(110, name, layout_spec_name(spec)); - if (!isupper(*name)) - error(109, "struct"); -} - -/* - * declstruct - declare a struct type - */ -static void declstruct(void) -{ - cell val; - char *str; - int tok; - pstruct_t *pstruct; - - /* get the explicit tag (required!) */ - tok = lex(&val,&str); - if (tok != tSYMBOL) { - error(93); - } else { - check_struct_name(str); - } - - pstruct = pstructs_add(str); - - pc_addtag_flags(pstruct->name, STRUCTTAG|FIXEDTAG); - - needtoken('{'); - do { - if (matchtoken('}')) { - /* Quick exit */ - lexpush(); - break; - } - - declinfo_t decl; - memset(&decl, 0, sizeof(decl)); - - decl.type.ident = iVARIABLE; - decl.type.size = 1; - if (!needtoken(tPUBLIC) || !parse_new_decl(&decl, NULL, DECLFLAG_FIELD)) { - // skip the rest of the line. - lexclr(TRUE); - break; - } - - structarg_t arg; - memset(&arg, 0, sizeof(arg)); - - arg.tag = decl.type.tag; - arg.dimcount = decl.type.numdim; - memcpy(arg.dims, decl.type.dim, sizeof(int) * arg.dimcount); - strcpy(arg.name, decl.name); - arg.fconst = !!(decl.type.usage & uCONST); - arg.ident = decl.type.ident; - if (arg.ident == iARRAY) - arg.ident = iREFARRAY; - - if (pstructs_addarg(pstruct, &arg) == NULL) - error(103, arg.name, layout_spec_name(Layout_PawnStruct)); - - require_newline(TRUE); - } while (!lexpeek('}')); - needtoken('}'); - matchtoken(';'); /* eat up optional semicolon */ -} - -// Consumes a line, returns FALSE if EOF hit. -static int consume_line() -{ - int val; - char *str; - - // First check for EOF. - if (lex(&val, &str) == 0) - return FALSE; - lexpush(); - - while (!matchtoken(tTERM)) { - // Check for EOF. - if (lex(&val, &str) == 0) - return FALSE; - } - - return TRUE; -} - -static int parse_new_typename(const token_t *tok) -{ - token_t tmp; - - if (!tok) { - lextok(&tmp); - tok = &tmp; - } - - switch (tok->id) { - case tINT: - return 0; - case tCHAR: - return pc_tag_string; - case tVOID: - return pc_tag_void; - case tOBJECT: - return pc_tag_object; - case tLABEL: - error(120); - return pc_addtag(tok->str); - case tSYMBOL: - { - if (strcmp(tok->str, "float") == 0) - return sc_rationaltag; - if (strcmp(tok->str, "bool") == 0) - return pc_tag_bool; - int tag = pc_findtag(tok->str); - if (tag == sc_rationaltag) { - error(98, "Float", "float"); - } else if (tag == pc_tag_string) { - error(98, "String", "char"); - } else if (tag == 0) { - error(98, "_", "int"); - } else if (tag == -1) { - error(139, tok->str); - tag = 0; - } else if (tag != pc_anytag) { - // Perform some basic filters so we can start narrowing down what can - // be used as a type. - if (!(tag & TAGTYPEMASK)) - error(139, tok->str); - } - return tag; - } - } - - error(122); - return -1; -} - -bool parse_new_typename(const token_t *tok, int *tagp) -{ - int tag = parse_new_typename(tok); - if (tag >= 0) - *tagp = tag; - else - *tagp = 0; - return true; -} - -static int parse_new_typeexpr(typeinfo_t *type, const token_t *first, int flags) -{ - token_t tok; - - if (first) - tok = *first; - else - lextok(&tok); - - if (tok.id == tCONST) { - if (type->usage & uCONST) - error(138); - type->usage |= uCONST; - lextok(&tok); - } - - if (!parse_new_typename(&tok, &type->tag)) - goto err_out; - - // Note: we could have already filled in the prefix array bits, so we check - // that ident != iARRAY before looking for an open bracket. - if (type->ident != iARRAY && matchtoken('[')) { - do { - if (type->numdim == sDIMEN_MAX) { - error(53); - break; - } - type->dim[type->numdim++] = 0; - if (!matchtoken(']')) { - error(140); - goto err_out; - } - } while (matchtoken('[')); - type->ident = iREFARRAY; - type->size = 0; - } - - if (flags & DECLFLAG_ARGUMENT) { - if (matchtoken('&')) { - if (type->ident == iARRAY) { - error(137); - goto err_out; - } - type->ident = iREFERENCE; - } - } - - type->tags[0] = type->tag; - type->numtags = 1; - return TRUE; - -err_out: - type->tags[0] = type->tag; - type->numtags = 1; - return FALSE; -} - -static void parse_old_array_dims(declinfo_t *decl, int flags) -{ - typeinfo_t *type = &decl->type; - constvalue **enumrootp; - - // Illegal declaration (we'll have a name since ref requires decl). - if (type->ident == iREFERENCE) - error(67, decl->name); - - if (flags & DECLFLAG_ENUMROOT) - enumrootp = &type->enumroot; - else - enumrootp = NULL; - - if (flags & DECLFLAG_DYNAMIC_ARRAYS) { - // This is a huge hack for declloc() - we'll generate the array code right - // into the staging buffer if needed. - cell staging_ptr; - int staging_index; - - int was_staging = staging; - if (!was_staging) - stgset(TRUE); - stgget(&staging_index, &staging_ptr); - - type->size = 0; - - do { - if (type->numdim == sDIMEN_MAX) { - error(53); - return; - } - - if (type->numdim > 0) { - // Push the last dimension size, which is in PRI. - pushreg(sPRI); - } - - if (matchtoken(']')) { - ldconst(0, sPRI); - type->idxtag[type->numdim] = 0; - type->dim[type->numdim] = 0; - type->numdim++; - continue; - } - - value val; - symbol *sym; - int ident = doexpr2( - TRUE, FALSE, FALSE, FALSE, - &type->idxtag[type->numdim], - &sym, 0, &val - ); - - if (ident == iVARIABLE || ident == iEXPRESSION || ident == iARRAYCELL) { - type->size = -1; - type->dim[type->numdim] = 0; - } else if (ident == iCONSTEXPR) { - if (val.constval > 0) { - if (type->size != -1) - type->size = val.constval; - type->dim[type->numdim] = val.constval; - } else { - error(9); - } - if (sym && sym->usage & uENUMROOT) - type->enumroot = sym->dim.enumlist; - type->idxtag[type->numdim] = sym ? sym->tag : 0; - } else { - error(29); - } - - type->numdim++; - needtoken(']'); - } while (matchtoken('[')); - - if (type->size >= 0) { - // Everything was constant. Drop the emitted assembly. - type->ident = iARRAY; - stgdel(staging_index, staging_ptr); - } else { - if (type->tag == pc_tag_string) - stradjust(sPRI); - pushreg(sPRI); - genarray(type->numdim, autozero); - type->ident = iREFARRAY; - type->size = 0; - if (type->is_new) { - // Fixed array with dynamic size. - error(161, pc_typename(type->tag)); - } - } - - stgout(staging_index); - if (!was_staging) - stgset(FALSE); - } else { - do { - if (type->numdim == sDIMEN_MAX) { - error(53); - return; - } - - type->size = needsub(&type->idxtag[type->numdim], enumrootp); - if (type->size > INT_MAX) - error(FATAL_ERROR_INT_OVERFLOW); - - type->dim[type->numdim++] = type->size; - } while (matchtoken('[')); - - type->ident = iARRAY; - } - - decl->type.has_postdims = TRUE; -} - -static int parse_old_decl(declinfo_t *decl, int flags) -{ - token_t tok; - typeinfo_t *type = &decl->type; - - if (matchtoken(tCONST)) { - if (type->usage & uCONST) - error(138); - type->usage |= uCONST; - } - - if (flags & DECLFLAG_ARGUMENT) { - if (matchtoken('&')) - type->ident = iREFERENCE; - - // grammar for multitags is: - // multi-tag ::= '{' (symbol (',' symbol)*)? '}' ':' - if (matchtoken('{')) { - while (type->numtags < MAXTAGS) { - int tag = 0; - - if (!matchtoken('_')) { - // If we don't get the magic tag '_', then we should have a symbol. - if (expecttoken(tSYMBOL, &tok)) - tag = pc_addtag(tok.str); - } - type->tags[type->numtags++] = tag; - - if (matchtoken('}')) - break; - needtoken(','); - } - needtoken(':'); - } - if (type->numtags > 1) - error(158); - } - - if (type->numtags == 0) { - if (matchtoken2(tLABEL, &tok)) - type->tags[type->numtags++] = pc_addtag(tok.str); - else - type->tags[type->numtags++] = 0; - } - - // All finished with tag stuff. - type->tag = type->tags[0]; - - // Look for varargs and end early. - if (matchtoken(tELLIPS)) { - type->ident = iVARARGS; - return TRUE; - } - - if (flags & DECLMASK_NAMED_DECL) { - if ((flags & DECLFLAG_MAYBE_FUNCTION) && matchtoken(tOPERATOR)) { - decl->opertok = operatorname(decl->name); - if (decl->opertok == 0) - strcpy(decl->name, "__unknown__"); - } else { - if (!lexpeek(tSYMBOL)) { - extern const char *sc_tokens[]; - switch (lextok(&tok)) { - case tOBJECT: - case tCHAR: - case tVOID: - case tINT: - if (lexpeek(tSYMBOL)) { - error(143); - } else { - error(157, sc_tokens[tok.id - tFIRST]); - strcpy(decl->name, sc_tokens[tok.id - tFIRST]); - } - break; - default: - lexpush(); - break; - } - } - if (expecttoken(tSYMBOL, &tok)) - strcpy(decl->name, tok.str); - else if (decl->name[0] == '\0') - strcpy(decl->name, "__unknown__"); - } - } - - if ((flags & DECLMASK_NAMED_DECL) && !decl->opertok) { - if (matchtoken('[')) - parse_old_array_dims(decl, flags); - } - - if (sc_require_newdecls) - error(147); - - return TRUE; -} - -static int reparse_old_decl(declinfo_t *decl, int flags) -{ - int usage = decl->type.usage & uCONST; - - memset(decl, 0, sizeof(*decl)); - decl->type.ident = iVARIABLE; - decl->type.size = 1; - decl->type.usage |= usage; - - return parse_old_decl(decl, flags); -} - -static int parse_new_decl(declinfo_t *decl, const token_t *first, int flags) -{ - token_t tok; - - if (!parse_new_typeexpr(&decl->type, first, flags)) - return FALSE; - - decl->type.is_new = TRUE; - - if (flags & DECLMASK_NAMED_DECL) { - if ((flags & DECLFLAG_ARGUMENT) && matchtoken(tELLIPS)) { - decl->type.ident = iVARARGS; - return TRUE; - } - - if ((flags & DECLFLAG_MAYBE_FUNCTION) && matchtoken(tOPERATOR)) { - decl->opertok = operatorname(decl->name); - if (decl->opertok == 0) - strcpy(decl->name, "__unknown__"); - } else { - if (!expecttoken(tSYMBOL, &tok)) { - strcpy(decl->name, "__unknown__"); - return FALSE; - } - strcpy(decl->name, tok.str); - } - } - - if (flags & DECLMASK_NAMED_DECL) { - if (matchtoken('[')) { - if (decl->type.numdim == 0) - parse_old_array_dims(decl, flags); - else - error(121); - } - } - - return TRUE; -} - -static int reparse_new_decl(declinfo_t *decl, int flags) -{ - token_t tok; - if (expecttoken(tSYMBOL, &tok)) - strcpy(decl->name, tok.str); - - if (decl->type.has_postdims) { - // We have something like: - // int x[], y... - // - // Reset the fact that we saw an array. - decl->type.numdim = 0; - decl->type.size = 0; - decl->type.enumroot = NULL; - decl->type.ident = iVARIABLE; - decl->type.size = 0; - decl->type.has_postdims = false; - if (matchtoken('[')) - parse_old_array_dims(decl, flags); - } else { - if (matchtoken('[')) { - if (decl->type.numdim > 0) - error(121); - parse_old_array_dims(decl, flags); - } else if (decl->type.numdim) { - // Reset dimension sizes. - memset(decl->type.dim, 0, sizeof(decl->type.dim[0]) * decl->type.numdim); - } - } - - return TRUE; -} - -// Parse a declaration. -// -// Grammar for named declarations is: -// "const"? symbol ('[' ']')* '&'? symbol -// | "const"? label? '&'? symbol '[' ']' -// -int parse_decl(declinfo_t *decl, int flags) -{ - token_ident_t ident; - - memset(decl, 0, sizeof(*decl)); - - decl->type.ident = iVARIABLE; - decl->type.size = 1; - - // Match early varargs as old decl. - if (lexpeek(tELLIPS)) - return parse_old_decl(decl, flags); - - // Must attempt to match const first, since it's a common prefix. - if (matchtoken(tCONST)) - decl->type.usage |= uCONST; - - // Sometimes we know ahead of time whether the declaration will be old, for - // example, if preceded by tNEW or tDECL. - if (flags & DECLFLAG_OLD) - return parse_old_decl(decl, flags); - if (flags & DECLFLAG_NEW) - return parse_new_decl(decl, NULL, flags); - - // If parsing an argument, there are two simple checks for whether this is a - // new or old-style declaration. - if ((flags & DECLFLAG_ARGUMENT) && (lexpeek('&') || lexpeek('{'))) - return parse_old_decl(decl, flags); - - // Another dead giveaway is there being a label or typeless operator. - if (lexpeek(tLABEL) || lexpeek(tOPERATOR)) - return parse_old_decl(decl, flags); - - // Otherwise, we have to eat a symbol to tell. - if (matchsymbol(&ident)) { - if (lexpeek(tSYMBOL) || - lexpeek(tOPERATOR) || - lexpeek('&') || - lexpeek(tELLIPS)) - { - // A new-style declaration only allows array dims or a symbol name, so - // this is a new-style declaration. - return parse_new_decl(decl, &ident.tok, flags); - } - - if ((flags & DECLMASK_NAMED_DECL) && matchtoken('[')) { - // Oh no - we have to parse array dims before we can tell what kind of - // declarator this is. It could be either: - // "x[] y" (new-style), or - // "y[]," (old-style) - parse_old_array_dims(decl, flags); - - if (matchtoken(tSYMBOL) || matchtoken('&')) { - // This must be a newdecl, "x[] y" or "x[] &y", the latter of which - // is illegal, but we flow it through the right path anyway. - lexpush(); - decl->type.has_postdims = false; - return parse_new_decl(decl, &ident.tok, flags); - } - - // The most basic - "x[]" and that's it. Well, we know it has no tag and - // we know its name. We might as well just complete the entire decl. - strcpy(decl->name, ident.name); - decl->type.tags[decl->type.numtags++] = 0; - decl->type.tag = decl->type.tags[0]; - return TRUE; - } - - // Give the symbol back to the lexer. This is an old decl. - lexpush(); - return parse_old_decl(decl, flags); - } - - // All else has failed. Probably got a type keyword. New-style. - return parse_new_decl(decl, NULL, flags); -} - -static void check_void_decl(const declinfo_t *decl, int variable) -{ - if (decl->type.tag != pc_tag_void) - return; - - if (variable) { - error(144); - return; - } - - if (decl->type.numdim > 0) { - error(145); - return; - } -} - -// Current lexer position is, we've parsed "public", an optional "native", and -// a type expression. -// -// This returns true if there is a method bind, i.e. "() = Y". -static int match_method_bind() -{ - // The grammar here is a little complicated. We must differentiate - // between two different rules: - // public X() = Y; - // public X() { ... - // - // If we parse up to '=', then it becomes harder to call newfunc() later, - // since ideally we'd like to back up to the '('. To work around this we - // use a hacked in lexer API to push older tokens back into the token - // stream. - token_t tok; - if (lextok(&tok) != '(') { - lexpush(); - return FALSE; - } - - if (!matchtoken(')')) { - lexpush(); - return FALSE; - } - - if (!matchtoken('=')) { - lexpush(); - lexpush(); - return FALSE; - } - - return TRUE; -} - -// If a name is too long, error and truncate. -void check_name_length(char *original) -{ - if (strlen(original) > sNAMEMAX) { - char buffer[METHOD_NAMEMAX + 1]; - strcpy(buffer, original); - buffer[sNAMEMAX] = '\0'; - error(123, original, buffer); - original[sNAMEMAX] = '\0'; - } -} - -static void make_primitive(typeinfo_t *type, int tag) -{ - memset(type, 0, sizeof(*type)); - type->tag = tag; - type->tags[type->numtags++] = type->tag; - type->ident = iVARIABLE; -} - -symbol *parse_inline_function(methodmap_t *map, - const typeinfo_t *type, - const char *name, - int is_native, - int is_ctor, - int is_dtor, - bool is_static) -{ - declinfo_t decl; - memset(&decl, 0, sizeof(decl)); - - if (is_dtor) { - make_primitive(&decl.type, pc_tag_void); - } else if (is_ctor) { - make_primitive(&decl.type, map->tag); - } else { - decl.type = *type; - } - decl.type.is_new = TRUE; - - const int *thistag = NULL; - if (!is_ctor && !is_static) - thistag = &map->tag; - - // Build a new symbol. Construct a temporary name including the class. - char fullname[METHOD_NAMEMAX + 1]; - strcpy(fullname, map->name); - strcat(fullname, "."); - strcat(fullname, name); - check_name_length(fullname); - strcpy(decl.name, fullname); - - symbol *target = NULL; - if (is_native) { - target = funcstub(tMETHODMAP, &decl, thistag); - } else { - int lcl_require_newdecls = sc_require_newdecls; - - sc_require_newdecls = TRUE; - int ok = newfunc(&decl, thistag, FALSE, FALSE, TRUE, &target); - sc_require_newdecls = lcl_require_newdecls; - - if (!ok) - return NULL; - if (!target || (target->usage & uFORWARD)) { - error(10); - return NULL; - } - } - return target; -} - -int check_this_tag(methodmap_t *map, symbol *target) -{ - // Check the implicit this parameter. Currently we only allow scalars. As - // to not encourage enum-structs, we will not allow those either. - const arginfo *first_arg = &target->dim.arglist[0]; - if (first_arg->ident == 0 || - first_arg->ident != iVARIABLE || - first_arg->hasdefault || - first_arg->numtags != 1) - { - return FALSE; - } - - // Ensure the methodmap tag is compatible with |this|. - int ok = FALSE; - for (methodmap_t *mapptr = map; mapptr; mapptr = mapptr->parent) { - if (first_arg->tags[0] == mapptr->tag) { - ok = TRUE; - break; - } - } - return ok; -} - -int parse_property_accessor(const typeinfo_t *type, methodmap_t *map, methodmap_method_t *method) -{ - token_ident_t ident; - int is_native = FALSE; - - needtoken(tPUBLIC); - if (!matchsymbol(&ident)) { - if (!matchtoken(tNATIVE)) { - error(125); - return FALSE; - } - is_native = TRUE; - if (!needsymbol(&ident)) - return FALSE; - } - - int getter = (strcmp(ident.name, "get") == 0); - int setter = (strcmp(ident.name, "set") == 0); - - if (!getter && !setter) { - error(125); - return FALSE; - } - - symbol *target = NULL; - - token_ident_t bindsource; - int is_bind = match_method_bind(); - if (is_bind) { - if (!needsymbol(&bindsource)) - return FALSE; - } - - if (is_bind) { - // Find an existing symbol. - target = findglb(bindsource.name, sGLOBAL); - if (!target) - error(17, bindsource.name); - else if (target->ident != iFUNCTN) - error(10); - } else { - typeinfo_t voidtype; - char tmpname[METHOD_NAMEMAX + 1]; - strcpy(tmpname, method->name); - if (getter) - strcat(tmpname, ".get"); - else - strcat(tmpname, ".set"); - - const typeinfo_t *ret_type; - if (getter) { - ret_type = type; - } else { - make_primitive(&voidtype, pc_tag_void); - ret_type = &voidtype; - } - - target = parse_inline_function(map, ret_type, tmpname, is_native, FALSE, FALSE, false); - } - - if (!target) - return FALSE; - - if (getter && method->getter) { - error(126, "getter", method->name); - return FALSE; - } - if (setter && method->setter) { - error(126, "setter", method->name); - return FALSE; - } - - if (getter) { - method->getter = target; - - // Cannot have extra arguments. - if (target->dim.arglist[0].ident && target->dim.arglist[1].ident) - error(127); - - if (!check_this_tag(map, target)) { - error(108, layout_spec_name(map->spec), map->name); - return FALSE; - } - - // Must return the same tag as the property. - if (type->tag != target->tag) { - const char *kind = getter ? "getter" : "setter"; - error(128, "getter", map->name, type_to_name(type->tag)); - } - } else { - method->setter = target; - - if (!check_this_tag(map, target)) { - error(108, layout_spec_name(map->spec), map->name); - return FALSE; - } - - // Must have one extra argument taking the return type. - arginfo *arg = &target->dim.arglist[1]; - if (arg->ident != iVARIABLE || - arg->hasdefault || - arg->numtags != 1 || - arg->tags[0] != type->tag) - { - error(150, pc_tagname(type->tag)); - return FALSE; - } - if (target->dim.arglist[2].ident) { - error(150, pc_tagname(type->tag)); - return FALSE; - } - if (target->tag != pc_tag_void) - error(151); - } - - require_newline(is_bind || (target->usage & uNATIVE)); - return TRUE; -} - -methodmap_method_t *parse_property(methodmap_t *map) -{ - typeinfo_t type; - token_ident_t ident; - methodmap_method_t *method; - - memset(&type, 0, sizeof(type)); - if (!parse_new_typeexpr(&type, NULL, 0)) - return NULL; - if (!needsymbol(&ident)) - return NULL; - - method = (methodmap_method_t *)calloc(1, sizeof(methodmap_method_t)); - strcpy(method->name, ident.name); - method->target = NULL; - method->getter = NULL; - method->setter = NULL; - - if (matchtoken('{')) { - while (!matchtoken('}')) { - if (!parse_property_accessor(&type, map,method)) - lexclr(TRUE); - } - - require_newline(FALSE); - } - - return method; -} - -methodmap_method_t *parse_method(methodmap_t *map) -{ - int maybe_ctor = 0; - int is_ctor = 0; - int is_dtor = 0; - int is_bind = 0; - int is_native = 0; - bool is_static = false; - const char *spectype = layout_spec_name(map->spec); - - if (matchtoken(tSTATIC)) - is_static = true; - - // This stores the name of the method (for destructors, we add a ~). - token_ident_t ident; - strcpy(ident.name, "__unknown__"); - - // For binding syntax, like X() = Y, this stores the right-hand name. - token_ident_t bindsource; - strcpy(bindsource.name, "__unknown__"); - - typeinfo_t type; - memset(&type, 0, sizeof(type)); - - // Destructors cannot be static. - if (!is_static && matchtoken('~')) { - // We got something like "public ~Blah = X" - is_bind = TRUE; - is_dtor = TRUE; - if (!needsymbol(&ident)) - return NULL; - if (!needtoken('(')) - return NULL; - if (!needtoken(')')) - return NULL; - if (!needtoken('=')) - return NULL; - if (!needsymbol(&bindsource)) - return NULL; - } else { - int got_symbol; - - is_native = matchtoken(tNATIVE); - got_symbol = matchsymbol(&ident); - - if (!is_native && got_symbol) { - // We didn't see "native", but we saw a symbol. Match for '() =' which - // would indicate a method bind. - is_bind = match_method_bind(); - - if (is_bind) { - // If we saw "X() =", then grab the right-hand name. - if (!needsymbol(&bindsource)) - return NULL; - } - } - - if (!is_bind) { - // All we know at this point is that we do NOT have a method bind. Keep - // pattern matching for an inline constructor, destructor, or method. - if (!got_symbol && matchtoken('~')) { - // ::= '~' ident - is_dtor = TRUE; - if (!needsymbol(&ident)) - return NULL; - } else if (got_symbol && matchtoken('(')) { - // ::= ident '(' - - // Push the '(' token back for declargs(). - maybe_ctor = TRUE; - lexpush(); - } else { - // The first token of the type expression is either the symbol we - // predictively parsed earlier, or it's been pushed back into the - // lex buffer. - const token_t *first = got_symbol ? &ident.tok : NULL; - - // Parse for type expression, priming it with the token we predicted - // would be an identifier. - if (!parse_new_typeexpr(&type, first, 0)) - return NULL; - - // Now, we should get an identifier. - if (!needsymbol(&ident)) - return NULL; - - // If the identifier is a constructor, error, since the user specified - // a type. - if (strcmp(ident.name, map->name) == 0) - error(99, "constructor"); - } - } else { - is_ctor = (strcmp(ident.name, map->name) == 0); - } - } // if (matchtoken('~')) - - // Do some preliminary verification of ctor/dtor names. - if (is_dtor) { - if (strcmp(ident.name, map->name) != 0) - error(114, "destructor", spectype, map->name); - - // Make sure the final name has "~" in it. - strcpy(ident.name, "~"); - strcat(ident.name, map->name); - check_name_length(ident.name); - } else if (maybe_ctor) { - if (strcmp(ident.name, map->name) == 0) - is_ctor = TRUE; - else - error(114, "constructor", spectype, map->name); - } - - if (is_ctor && is_static) { - // Constructors may not be static. - error(175); - } - - symbol *target = NULL; - if (is_bind) { - // Find an existing symbol. - target = findglb(bindsource.name, sGLOBAL); - if (!target) - error(17, bindsource.name); - else if (target->ident != iFUNCTN) - error(10); - } else { - target = parse_inline_function(map, &type, ident.name, is_native, is_ctor, is_dtor, is_static); - } - - if (!target) - return NULL; - - // Verify destructor targets. - if (is_dtor) { - if (!(target->usage & uNATIVE)) { - // Must be a native. - error(118); - return NULL; - } - - if (target->tag != 0 && target->tag != pc_tag_void) { - // Cannot return a value. - error(99, "destructor"); - return NULL; - } - - if (target->dim.arglist[0].ident && target->dim.arglist[1].ident) { - // Cannot have extra arguments. - error(119); - return NULL; - } - } - - // Verify constructor targets. - if (is_ctor) { - if (target->tag != map->tag) - error(112, map->name); - } - - methodmap_method_t *method = (methodmap_method_t *)calloc(1, sizeof(methodmap_method_t)); - strcpy(method->name, ident.name); - method->target = target; - method->getter = NULL; - method->setter = NULL; - method->is_static = is_static; - - // If the symbol is a constructor, we bypass the initial argument checks. - if (is_ctor) { - if (map->ctor) - error(113, map->name); - } else if (!is_static) { - if (!check_this_tag(map, target)) - error(108, spectype, map->name); - } - - if (is_dtor) - map->dtor = method; - if (is_ctor) - map->ctor = method; - - require_newline(is_bind || (target->usage & uNATIVE)); - return method; -} - -/** - * domethodmap - declare a method map for OO-ish syntax. - * - */ -static void domethodmap(LayoutSpec spec) -{ - int val; - char *str; - methodmap_t *parent = NULL; - const char *spectype = layout_spec_name(spec); - - // methodmap ::= "methodmap" symbol ("<" symbol)? "{" methodmap-body "}" - char mapname[sNAMEMAX + 1]; - if (lex(&val, &str) != tSYMBOL) - error(93); - strcpy(mapname, str); - - if (!isupper(*mapname)) - error(109, spectype); - - LayoutSpec old_spec = deduce_layout_spec_by_name(mapname); - int can_redef = can_redef_layout_spec(spec, old_spec); - if (!can_redef) - error(110, mapname, layout_spec_name(old_spec)); - - if (matchtoken('<')) { - if (lex(&val, &str) != tSYMBOL) { - error(93); - return; - } - - if ((parent = methodmap_find_by_name(str)) == NULL) { - error(102, spectype, str); - } else if (parent->spec != spec) { - error(129); - } - } - - methodmap_t *map = (methodmap_t *)calloc(1, sizeof(methodmap_t)); - map->parent = parent; - map->spec = spec; - strcpy(map->name, mapname); - if (spec == Layout_MethodMap) { - map->tag = pc_addtag_flags(mapname, FIXEDTAG | METHODMAPTAG); - - if (matchtoken(tNULLABLE) || (parent && parent->nullable)) - map->nullable = TRUE; - } else { - map->tag = pc_addtag_flags(mapname, FIXEDTAG | OBJECTTAG); - } - methodmap_add(map); - - if (can_redef) { - symbol *sym = findglb(mapname, sGLOBAL); - if (sym && sym->ident != iMETHODMAP) { - // We should only hit this on the first pass. Assert really hard that - // we're about to kill an enum definition and not something random. - assert(sc_status == statFIRST); - assert(sym->ident == iCONSTEXPR); - assert(TAGID(map->tag) == TAGID(sym->tag)); - - sym->ident = iMETHODMAP; - - // Kill previous enumstruct properties, if any. - if (sym->usage & uENUMROOT) { - for (constvalue *cv = sym->dim.enumlist; cv; cv = cv->next) { - symbol *csym = findglb(cv->name, sGLOBAL); - if (csym && - csym->ident == iCONSTEXPR && - csym->parent == sym && - (csym->usage & uENUMFIELD)) - { - csym->usage &= ~uENUMFIELD; - csym->parent = NULL; - } - } - delete_consttable(sym->dim.enumlist); - free(sym->dim.enumlist); - sym->dim.enumlist = NULL; - } - } else if (!sym) { - sym = addsym( - mapname, // name - 0, // addr - iMETHODMAP, // ident - sGLOBAL, // vclass - map->tag, // tag - uDEFINE); // usage - } - sym->methodmap = map; - } - - needtoken('{'); - while (!matchtoken('}')) { - token_t tok; - methodmap_method_t **methods; - methodmap_method_t *method = NULL; - - if (lextok(&tok) == tPUBLIC) { - method = parse_method(map); - } else if (tok.id == tSYMBOL && strcmp(tok.str, "property") == 0) { - method = parse_property(map); - } else { - error(124); - } - - if (method) { - // Check that a method with this name doesn't already exist. - for (size_t i = 0; i < map->nummethods; i++) { - if (strcmp(map->methods[i]->name, method->name) == 0) { - error(103, method->name, spectype); - method = NULL; - break; - } - } - } - - if (!method) { - if (!consume_line()) - return; - continue; - } - - methods = (methodmap_method_t **)realloc(map->methods, sizeof(methodmap_method_t *) * (map->nummethods + 1)); - if (!methods) { - error(FATAL_ERROR_OOM); - return; - } - map->methods = methods; - map->methods[map->nummethods++] = method; - } - - require_newline(TRUE); -} - -class AutoStage -{ - public: - AutoStage() : lcl_staging_(FALSE) - { - if (!staging) { - stgset(TRUE); - lcl_staging_ = TRUE; - lcl_stgidx_ = stgidx; - assert(stgidx == 0); - } - } - ~AutoStage() { - if (lcl_staging_) { - stgout(lcl_stgidx_); - stgset(FALSE); - } - } - - private: - int lcl_staging_; - int lcl_stgidx_; -}; - -// delete ::= "delete" expr -static void dodelete() -{ - AutoStage staging_on; - - svalue sval; - int ident = lvalexpr(&sval); - needtoken(tTERM); - - switch (ident) { - case iFUNCTN: - case iREFFUNC: - error(167, "functions"); - return; - - case iARRAY: - case iREFARRAY: - case iARRAYCELL: - case iARRAYCHAR: - { - symbol *sym = sval.val.sym; - if (!sym || sym->dim.array.level > 0) { - error(167, "arrays"); - return; - } - break; - } - } - - if (sval.val.tag == 0) { - error(167, "integers"); - return; - } - - methodmap_t *map = methodmap_find_by_tag(sval.val.tag); - if (!map) { - error(115, "type", pc_tagname(sval.val.tag)); - return; - } - - { - methodmap_t *iter = map; - while (iter) { - if (iter->dtor) { - map = iter; - break; - } - iter = iter->parent; - } - } - - if (!map || !map->dtor) { - error(115, layout_spec_name(map->spec), map->name); - return; - } - - // Only zap non-const lvalues. - int zap = sval.lvalue; - if (zap && sval.val.sym && (sval.val.sym->usage & uCONST)) - zap = FALSE; - - int popaddr = FALSE; - methodmap_method_t *accessor = NULL; - if (sval.lvalue) { - if (zap) { - switch (sval.val.ident) { - case iACCESSOR: - // rvalue() removes iACCESSOR so we store it locally. - accessor = sval.val.accessor; - if (!accessor->setter) { - zap = FALSE; - break; - } - pushreg(sPRI); - popaddr = TRUE; - break; - case iARRAYCELL: - case iARRAYCHAR: - pushreg(sPRI); - popaddr = TRUE; - break; - } - } - - rvalue(&sval.val); - } - - // push.pri - // push.c 1 - // sysreq.c N 1 - // stack 8 - pushreg(sPRI); - { - pushval(1); - ffcall(map->dtor->target, NULL, 1); - - // Only mark usage if we're not skipping codegen. - if (sc_status != statSKIP) - markusage(map->dtor->target, uREAD); - } - - if (zap) { - if (popaddr) - popreg(sALT); - - // Store 0 back. - ldconst(0, sPRI); - if (accessor) - invoke_setter(accessor, FALSE); - else - store(&sval.val); - } - - markexpr(sEXPR, NULL, 0); -} - -/** - * function-type ::= "(" function-type-inner ")" - * | function-type-inner - * function-type-inner ::= "function" type-expr "(" new-style-args ")" - */ -static void parse_function_type(functag_t *type) -{ - memset(type, 0, sizeof(*type)); - - int lparen = matchtoken('('); - needtoken(tFUNCTION); - - parse_new_typename(NULL, &type->ret_tag); - type->usage = uPUBLIC; - - needtoken('('); - - while (!matchtoken(')')) { - declinfo_t decl; - - // Initialize. - memset(&decl, 0, sizeof(decl)); - decl.type.ident = iVARIABLE; - - parse_new_decl(&decl, NULL, DECLFLAG_ARGUMENT); - - // Eat optional symbol name. - matchtoken(tSYMBOL); - - // Error once when we're past max args. - if (type->argcount == sARGS_MAX) { - error(45); - continue; - } - - // Account for strings. - fix_char_size(&decl); - - funcarg_t *arg = &type->args[type->argcount++]; - arg->tagcount = 1; - arg->tags[0] = decl.type.tag; - arg->dimcount = decl.type.numdim; - memcpy(arg->dims, decl.type.dim, arg->dimcount * sizeof(decl.type.dim[0])); - arg->fconst = (decl.type.usage & uCONST) ? TRUE : FALSE; - if (decl.type.ident == iARRAY) - arg->ident = iREFARRAY; - else - arg->ident = decl.type.ident; - - if (!matchtoken(',')) { - needtoken(')'); - break; - } - } - - if (lparen) - needtoken(')'); - - require_newline(TRUE); - errorset(sRESET, 0); -} - -static void dotypedef() -{ - token_ident_t ident; - if (!needsymbol(&ident)) - return; - - int prev_tag = pc_findtag(ident.name); - if (prev_tag != -1 && !(prev_tag & FUNCTAG)) - error(94); - - needtoken('='); - - funcenum_t *def = funcenums_add(ident.name); - - functag_t type; - parse_function_type(&type); - functags_add(def, &type); -} - -// Unsafe typeset - only supports function types. This is a transition hack for SP2. -static void dotypeset() -{ - token_ident_t ident; - if (!needsymbol(&ident)) - return; - - int prev_tag = pc_findtag(ident.name); - if (prev_tag != -1 && !(prev_tag & FUNCTAG)) - error(94); - - funcenum_t *def = funcenums_add(ident.name); - needtoken('{'); - while (!matchtoken('}')) { - functag_t type; - parse_function_type(&type); - functags_add(def, &type); - } - - require_newline(TRUE); -} - -/** - * dofuncenum - declare function enumerations - */ -static void dofuncenum(int listmode) -{ - cell val; - char *str; - // char *ptr; - char tagname[sNAMEMAX+1]; - constvalue *cur; - funcenum_t *fenum = NULL; - int i; - int newStyleTag = 0; - int isNewStyle = 0; - - /* get the explicit tag (required!) */ - int l = lex(&val,&str); - if (l != tSYMBOL) { - if (listmode == FALSE && l == tPUBLIC) { - isNewStyle = TRUE; - switch (lex(&val, &str)) { - case tOBJECT: - newStyleTag = pc_tag_object; - break; - case tINT: - newStyleTag = 0; - break; - case tVOID: - newStyleTag = pc_tag_void; - break; - case tCHAR: - newStyleTag = pc_tag_string; - break; - case tLABEL: - newStyleTag = pc_addtag(str); - break; - case tSYMBOL: - // Check whether this is new-style declaration. - // we'll port this all to parse_decl() sometime. - if (lexpeek('(')) - lexpush(); - else - newStyleTag = pc_addtag(str); - break; - default: - error(93); - } - - if (!needtoken(tSYMBOL)) { - lexclr(TRUE); - litidx = 0; - return; - } - l = tokeninfo(&val, &str); - } else { - error(93); - } - } - - /* This tag can't already exist! */ - cur=tagname_tab.next; - while (cur) { - if (strcmp(cur->name, str) == 0) { - /* Another bad one... */ - if (!(cur->value & FUNCTAG)) - error(94); - break; - } - cur = cur->next; - } - strcpy(tagname, str); - - fenum = funcenums_add(tagname); - - if (listmode) - needtoken('{'); - do { - functag_t func; - if (listmode && matchtoken('}')) { - /* Quick exit */ - lexpush(); - break; - } - memset(&func, 0, sizeof(func)); - if (!isNewStyle) { - func.ret_tag = pc_addtag(NULL); /* Get the return tag */ - l = lex(&val, &str); - /* :TODO: - * Right now, there is a problem. We can't pass non-public function pointer addresses around, - * because the address isn't known until the final reparse. Unfortunately, you can write code - * before the address is known, because Pawn's compiler isn't truly multipass. - * - * When you call a function, there's no problem, because it does not write the address. - * The assembly looks like this: - * call MyFunction - * Then, only at assembly time (once all passes are done), does it know the address. - * I do not see any solution to this because there is no way I know to inject the function name - * rather than the constant value. And even if we could, we'd have to change the assembler recognize that. - */ - if (l == tPUBLIC) { - func.usage = uPUBLIC; - } else { - error(1, "-public-", str); - } - } else { - func.ret_tag = newStyleTag; - func.usage = uPUBLIC; - } - needtoken('('); - do { - funcarg_t *arg = &(func.args[func.argcount]); - - /* Quick exit */ - if (matchtoken(')')) { - lexpush(); - break; - } - l = lex(&val, &str); - if (l == '&') { - if ((arg->ident != iVARIABLE && arg->ident != 0) || arg->tagcount > 0) - error(1, "-identifier-", "&"); - arg->ident = iREFERENCE; - } else if (l == tCONST) { - if ((arg->ident != iVARIABLE && arg->ident != 0) || arg->tagcount > 0) - error(1, "-identifier-", "const"); - arg->fconst=TRUE; - } else if (l == tLABEL) { - if (arg->tagcount > 0) - error(1, "-identifier-", "-tagname-"); - arg->tags[arg->tagcount++] = pc_addtag(str); - l=tLABEL; - } else if (l == tSYMBOL) { - if (func.argcount >= sARGS_MAX) - error(45); - if (str[0] == PUBLIC_CHAR) - error(56, str); - if (matchtoken('[')) - { - cell size; - if (arg->ident == iREFERENCE) - error(67, str); - do { - constvalue *enumroot; - int ignore_tag; - if (arg->dimcount == sDIMEN_MAX) { - error(53); - break; - } - size = needsub(&ignore_tag, &enumroot); - arg->dims[arg->dimcount] = size; - arg->dimcount += 1; - } while (matchtoken('[')); - /* Handle strings */ - if ((arg->tagcount == 1 && arg->tags[0] == pc_tag_string) - && arg->dims[arg->dimcount-1]) - { - arg->dims[arg->dimcount-1] = (size + sizeof(cell)-1) / sizeof(cell); - } - arg->ident=iREFARRAY; - } else if (arg->ident == 0) { - arg->ident = iVARIABLE; - } - - if (matchtoken('=')) { - needtoken('0'); - arg->ommittable = TRUE; - func.ommittable = TRUE; - } else if (func.ommittable) { - error(95); - } - func.argcount++; - } else if (l == tELLIPS) { - if (arg->ident == iVARIABLE) - error(10); - arg->ident = iVARARGS; - func.argcount++; - } else { - error(10); - } - } while (l == '&' || l == tLABEL || l == tCONST || (l != tELLIPS && matchtoken(','))); - needtoken(')'); - for (i=0; i0) - multiplier*=2; - } /* if */ - needtoken(')'); - } /* if */ - - if (strlen(enumname)>0) { - if (vclass == sGLOBAL) { - if ((enumsym = findglb(enumname, vclass)) != NULL) { - // If we were previously defined as a methodmap, don't overwrite the - // symbol. Otherwise, flow into add_constant where we will error. - if (enumsym->ident != iMETHODMAP) - enumsym = nullptr; - } - } - - if (!enumsym) { - /* create the root symbol, so the fields can have it as their "parent" */ - enumsym=add_constant(enumname,0,vclass,tag); - if (enumsym!=NULL) - enumsym->usage |= uENUMROOT; - /* start a new list for the element names */ - if ((enumroot=(constvalue*)malloc(sizeof(constvalue)))==NULL) - error(FATAL_ERROR_OOM); /* insufficient memory (fatal error) */ - memset(enumroot,0,sizeof(constvalue)); - } - } else { - enumsym=NULL; - enumroot=NULL; - } /* if */ - - // If this enum is for a methodmap, forget the symbol so code below doesn't - // build an enum struct. - if (enumsym && enumsym->ident == iMETHODMAP) - enumsym = NULL; - - needtoken('{'); - /* go through all constants */ - value=0; /* default starting value */ - do { - int idxtag,fieldtag; - symbol *sym; - if (matchtoken('}')) { /* quick exit if '}' follows ',' */ - lexpush(); - break; - } /* if */ - idxtag=pc_addtag(NULL); /* optional explicit item tag */ - if (needtoken(tSYMBOL)) { /* read in (new) token */ - tokeninfo(&val,&str); /* get the information */ - strcpy(constname,str); /* save symbol name */ - } else { - constname[0]='\0'; - } /* if */ - size=increment; /* default increment of 'val' */ - fieldtag=0; /* default field tag */ - if (matchtoken('[')) { - exprconst(&size,&fieldtag,NULL); /* get size */ - needtoken(']'); - } /* if */ - /* :TODO: do we need a size modifier here for pc_tag_string? */ - if (matchtoken('=')) - exprconst(&value,NULL,NULL); /* get value */ - /* add_constant() checks whether a variable (global or local) or - * a constant with the same name already exists - */ - sym=add_constant(constname,value,vclass,tag); - if (sym==NULL) - continue; /* error message already given */ - /* set the item tag and the item size, for use in indexing arrays */ - sym->x.tags.index=idxtag; - sym->x.tags.field=fieldtag; - sym->dim.array.length=size; - sym->dim.array.level=0; - sym->dim.array.slength=0; - sym->parent=enumsym; - /* add the constant to a separate list as well */ - if (enumroot!=NULL) { - sym->usage |= uENUMFIELD; - append_constval(enumroot,constname,value,tag); - } /* if */ - if (multiplier==1) - value+=size; - else - value*=size*multiplier; - } while (matchtoken(',')); - needtoken('}'); /* terminates the constant list */ - matchtoken(';'); /* eat an optional ; */ - - /* set the enum name to the "next" value (typically the last value plus one) */ - if (enumsym) { - assert((enumsym->usage & uENUMROOT)!=0); - enumsym->addr=value; - /* assign the constant list */ - assert(enumroot!=NULL); - enumsym->dim.enumlist=enumroot; - sc_attachdocumentation(enumsym); /* attach any documenation to the enumeration */ - } /* if */ -} - -static int getstates(const char *funcname) -{ - char fsaname[sNAMEMAX+1],statename[sNAMEMAX+1]; - cell val; - char *str; - constvalue *automaton; - constvalue *state; - int fsa,islabel; - int *list; - int count,listsize,state_id; - - if (!matchtoken('<')) - return 0; - if (matchtoken('>')) - return -1; /* special construct: all other states (fall-back) */ - - count=0; - listsize=0; - list=NULL; - fsa=-1; - - do { - if (!(islabel=matchtoken(tLABEL)) && !needtoken(tSYMBOL)) - break; - tokeninfo(&val,&str); - assert(strlen(str)=0 && automaton->index!=fsa) - error(83,funcname); /* multiple automatons for a single function/variable */ - fsa=automaton->index; - } /* if */ - state=state_add(statename,fsa); - /* add this state to the state combination list (it will be attached to the - * automaton later) */ - state_buildlist(&list,&listsize,&count,(int)state->value); - } while (matchtoken(',')); - needtoken('>'); - - if (count>0) { - assert(automaton!=NULL); - assert(fsa>=0); - state_id=state_addlist(list,count,fsa); - assert(state_id>0); - } else { - /* error is already given */ - state_id=0; - } /* if */ - if (list!=NULL) - free(list); - - return state_id; -} - -static void attachstatelist(symbol *sym, int state_id) -{ - assert(sym!=NULL); - if ((sym->usage & uDEFINE)!=0 && (sym->states==NULL || state_id==0)) - error(21,sym->name); /* function already defined, either without states or the current definition has no states */ - - if (state_id!=0) { - /* add the state list id */ - constvalue *stateptr; - if (sym->states==NULL) { - if ((sym->states=(constvalue*)malloc(sizeof(constvalue)))==NULL) - error(FATAL_ERROR_OOM); /* insufficient memory (fatal error) */ - memset(sym->states,0,sizeof(constvalue)); - } /* if */ - /* see whether the id already exists (add new state only if it does not - * yet exist - */ - assert(sym->states!=NULL); - for (stateptr=sym->states->next; stateptr!=NULL && stateptr->index!=state_id; stateptr=stateptr->next) - /* nothing */; - assert(state_id<=SHRT_MAX); - if (stateptr==NULL) - append_constval(sym->states,"",code_idx,(short)state_id); - else if (stateptr->value==0) - stateptr->value=code_idx; - else - error(84,sym->name); - /* also check for another conflicting situation: a fallback function - * without any states - */ - if (state_id==-1 && sc_status!=statFIRST) { - /* in the second round, all states should have been accumulated */ - assert(sym->states!=NULL); - for (stateptr=sym->states->next; stateptr!=NULL && stateptr->index==-1; stateptr=stateptr->next) - /* nothing */; - if (stateptr==NULL) - error(85,sym->name); /* no states are defined for this function */ - } /* if */ - } /* if */ -} - -// This simpler version of matchtag() only checks whether two tags represent -// the same type. Because methodmaps are attached to types and are not actually -// types themselves, we strip out the methodmap bit in case a methodmap was -// seen later than another instance of a tag. -static int compare_tag(int tag1, int tag2) -{ - return (tag1 & (~METHODMAPTAG)) == (tag2 & (~METHODMAPTAG)); -} - -/* - * Finds a function in the global symbol table or creates a new entry. - * It does some basic processing and error checking. - */ -symbol *fetchfunc(char *name) -{ - symbol *sym; - - if ((sym=findglb(name,sGLOBAL))!=0) { /* already in symbol table? */ - if (sym->ident!=iFUNCTN) { - error(21,name); /* yes, but not as a function */ - return NULL; /* make sure the old symbol is not damaged */ - } else if ((sym->usage & uNATIVE)!=0) { - error(21,name); /* yes, and it is a native */ - } /* if */ - assert(sym->vclass==sGLOBAL); - } else { - /* don't set the "uDEFINE" flag; it may be a prototype */ - sym=addsym(name,code_idx,iFUNCTN,sGLOBAL,0,0); - assert(sym!=NULL); /* fatal error 103 must be given on error */ - /* assume no arguments */ - sym->dim.arglist=(arginfo*)calloc(1, sizeof(arginfo)); - /* set library ID to NULL (only for native functions) */ - sym->x.lib=NULL; - /* set the required stack size to zero (only for non-native functions) */ - sym->x.stacksize=1; /* 1 for PROC opcode */ - } /* if */ - if (pc_deprecate!=NULL) { - assert(sym!=NULL); - sym->flags|=flgDEPRECATED; - if (sc_status==statWRITE) { - if (sym->documentation!=NULL) { - free(sym->documentation); - sym->documentation=NULL; - } /* if */ - sym->documentation=pc_deprecate; - } else { - free(pc_deprecate); - } /* if */ - pc_deprecate=NULL; - } /* if */ - - return sym; -} - -/* This routine adds symbolic information for each argument. - */ -static void define_args(void) -{ - symbol *sym; - - /* At this point, no local variables have been declared. All - * local symbols are function arguments. - */ - sym=loctab.next; - while (sym!=NULL) { - assert(sym->ident!=iLABEL); - assert(sym->vclass==sLOCAL); - markexpr(sLDECL,sym->name,sym->addr); /* mark for better optimization */ - sym=sym->next; - } /* while */ -} - -static int operatorname(char *name) -{ - int opertok; - char *str; - cell val; - - assert(name!=NULL); - - /* check the operator */ - opertok=lex(&val,&str); - switch (opertok) { - case '+': - case '-': - case '*': - case '/': - case '%': - case '>': - case '<': - case '!': - case '~': - case '=': - name[0]=(char)opertok; - name[1]='\0'; - break; - case tINC: - strcpy(name,"++"); - break; - case tDEC: - strcpy(name,"--"); - break; - case tlEQ: - strcpy(name,"=="); - break; - case tlNE: - strcpy(name,"!="); - break; - case tlLE: - strcpy(name,"<="); - break; - case tlGE: - strcpy(name,">="); - break; - default: - name[0]='\0'; - error(7); /* operator cannot be redefined (or bad operator name) */ - return 0; - } /* switch */ - - return opertok; -} - -static int operatoradjust(int opertok,symbol *sym,char *opername,int resulttag) -{ - int tags[2]={0,0}; - int count=0; - arginfo *arg; - char tmpname[sNAMEMAX+1]; - symbol *oldsym; - - if (opertok==0) - return TRUE; - - assert(sym!=NULL && sym->ident==iFUNCTN && sym->dim.arglist!=NULL); - /* count arguments and save (first two) tags */ - while (arg=&sym->dim.arglist[count], arg->ident!=0) { - if (count<2) { - if (arg->numtags>1) - error(65,count+1); /* function argument may only have a single tag */ - else if (arg->numtags==1) - tags[count]=arg->tags[0]; - } /* if */ - if (opertok=='~' && count==0) { - if (arg->ident!=iREFARRAY) - error(73,arg->name);/* must be an array argument */ - } else { - //if (arg->ident!=iVARIABLE) - //error(66,arg->name);/* must be non-reference argument */ - } /* if */ - if (arg->hasdefault) - error(59,arg->name); /* arguments of an operator may not have a default value */ - count++; - } /* while */ - - /* for '!', '++' and '--', count must be 1 - * for '-', count may be 1 or 2 - * for '=', count must be 1, and the resulttag is also important - * for all other (binary) operators and the special '~' operator, count must be 2 - */ - switch (opertok) { - case '!': - case '=': - case tINC: - case tDEC: - if (count!=1) - error(62); /* number or placement of the operands does not fit the operator */ - break; - case '-': - if (count!=1 && count!=2) - error(62); /* number or placement of the operands does not fit the operator */ - break; - default: - if (count!=2) - error(62); /* number or placement of the operands does not fit the operator */ - } /* switch */ - - if (tags[0]==0 && ((opertok!='=' && tags[1]==0) || (opertok=='=' && resulttag==0))) - error(64); /* cannot change predefined operators */ - - /* change the operator name */ - assert(strlen(opername)>0); - operator_symname(tmpname,opername,tags[0],tags[1],count,resulttag); - if ((oldsym=findglb(tmpname,sGLOBAL))!=NULL) { - int i; - if ((oldsym->usage & uDEFINE)!=0) { - char errname[2*sNAMEMAX+16]; - funcdisplayname(errname,tmpname); - error(21,errname); /* symbol already defined */ - } /* if */ - sym->usage|=oldsym->usage; /* copy flags from the previous definition */ - for (i=0; inumrefers; i++) - if (oldsym->refer[i]!=NULL) - refer_symbol(sym,oldsym->refer[i]); - delete_symbol(&glbtab,oldsym); - } /* if */ - RemoveFromHashTable(sp_Globals, sym); - strcpy(sym->name,tmpname); - sym->hash=NameHash(sym->name);/* calculate new hash */ - AddToHashTable(sp_Globals, sym); - - /* operators should return a value, except the '~' operator */ - if (opertok!='~') - sym->usage |= uRETVALUE; - - return TRUE; -} - -static int check_operatortag(int opertok,int resulttag,char *opername) -{ - assert(opername!=NULL && strlen(opername)>0); - switch (opertok) { - case '!': - case '<': - case '>': - case tlEQ: - case tlNE: - case tlLE: - case tlGE: - if (resulttag!=pc_tag_bool) { - error(63,opername,"bool:"); /* operator X requires a "bool:" result tag */ - return FALSE; - } /* if */ - break; - case '~': - if (resulttag!=0) { - error(63,opername,"_:"); /* operator "~" requires a "_:" result tag */ - return FALSE; - } /* if */ - break; - } /* switch */ - return TRUE; -} - -static char *tag2str(char *dest,int tag) -{ - assert(tag>=0); - sprintf(dest,"0%x",tag); - return isdigit(dest[1]) ? &dest[1] : dest; -} - -char *operator_symname(char *symname,const char *opername,int tag1,int tag2,int numtags,int resulttag) -{ - char tagstr1[10], tagstr2[10]; - int opertok; - - assert(numtags>=1 && numtags<=2); - opertok= (opername[1]=='\0') ? opername[0] : 0; - if (opertok=='=') - sprintf(symname,"%s%s%s",tag2str(tagstr1,resulttag),opername,tag2str(tagstr2,tag1)); - else if (numtags==1 || opertok=='~') - sprintf(symname,"%s%s",opername,tag2str(tagstr1,tag1)); - else - sprintf(symname,"%s%s%s",tag2str(tagstr1,tag1),opername,tag2str(tagstr2,tag2)); - return symname; -} - -static int parse_funcname(char *fname,int *tag1,int *tag2,char *opname) -{ - char *ptr,*name; - int unary; - - /* tags are only positive, so if the function name starts with a '-', - * the operator is an unary '-' or '--' operator. - */ - if (*fname=='-') { - *tag1=0; - unary=TRUE; - ptr=fname; - } else { - *tag1=(int)strtol(fname,&ptr,16); - unary= ptr==fname; /* unary operator if it doesn't start with a tag name */ - } /* if */ - assert(!unary || *tag1==0); - assert(*ptr!='\0'); - for (name=opname; !isdigit(*ptr); ) - *name++ = *ptr++; - *name='\0'; - *tag2=(int)strtol(ptr,NULL,16); - return unary; -} - -constvalue *find_tag_byval(int tag) -{ - return find_constval_byval(&tagname_tab, tag); -} - -char *funcdisplayname(char *dest,char *funcname) -{ - int tags[2]; - char opname[10]; - constvalue *tagsym[2]; - int unary; - - if (isalpha(*funcname) || *funcname=='_' || *funcname==PUBLIC_CHAR || *funcname=='\0') { - if (dest!=funcname) - strcpy(dest,funcname); - return dest; - } /* if */ - - unary=parse_funcname(funcname,&tags[0],&tags[1],opname); - tagsym[1]=find_tag_byval(tags[1]); - assert(tagsym[1]!=NULL); - if (unary) { - sprintf(dest,"operator%s(%s:)",opname,tagsym[1]->name); - } else { - tagsym[0]=find_tag_byval(tags[0]); - assert(tagsym[0]!=NULL); - /* special case: the assignment operator has the return value as the 2nd tag */ - if (opname[0]=='=' && opname[1]=='\0') - sprintf(dest,"%s:operator%s(%s:)",tagsym[0]->name,opname,tagsym[1]->name); - else - sprintf(dest,"operator%s(%s:,%s:)",opname,tagsym[0]->name,tagsym[1]->name); - } /* if */ - return dest; -} - -static cell char_array_cells(cell size) -{ - return (size + sizeof(cell) - 1) / sizeof(cell); -} - -static cell fix_char_size(declinfo_t *decl) -{ - typeinfo_t *type = &decl->type; - if (type->tag == pc_tag_string && type->numdim && type->dim[type->numdim - 1]) { - cell slength = type->dim[type->numdim - 1]; - type->dim[type->numdim - 1] = char_array_cells(type->size); - return slength; - } - return 0; -} - -static symbol *funcstub(int tokid, declinfo_t *decl, const int *thistag) -{ - char *str; - cell val; - symbol *sym; - int fnative = (tokid == tNATIVE || tokid == tMETHODMAP); - int fpublic = (tokid == tPUBLIC); - - lastst=0; - litidx=0; /* clear the literal pool */ - assert(loctab.next==NULL); /* local symbol table should be empty */ - - fix_char_size(decl); - - if (decl->opertok) - check_operatortag(decl->opertok, decl->type.tag, decl->name); - - needtoken('('); /* only functions may be native/forward */ - - sym=fetchfunc(decl->name); - if (sym==NULL) - return NULL; - if ((sym->usage & uPROTOTYPED)!=0 && !compare_tag(sym->tag, decl->type.tag)) - error(25); - if ((sym->usage & uDEFINE) == 0) { - // As long as the function stays undefined, update its address and tag. - sym->addr = code_idx; - sym->tag = decl->type.tag; - } - - if (fnative) { - sym->usage=(char)(uNATIVE | uRETVALUE | uDEFINE | (sym->usage & uPROTOTYPED)); - sym->x.lib=curlibrary; - } else if (fpublic) { - sym->usage|=uPUBLIC; - } /* if */ - sym->usage|=uFORWARD; - - declargs(sym, FALSE, thistag); - /* "declargs()" found the ")" */ - sc_attachdocumentation(sym); /* attach any documenation to the function */ - if (!operatoradjust(decl->opertok,sym,decl->name,decl->type.tag)) - sym->usage &= ~uDEFINE; - - if (getstates(decl->name)!=0) { - if (fnative || decl->opertok!=0) - error(82); /* native functions and operators may not have states */ - else - error(231); /* ignoring state specifications on forward declarations */ - } /* if */ - - /* for a native operator, also need to specify an "exported" function name; - * for a native function, this is optional - */ - if (fnative) { - if (decl->opertok!=0) { - needtoken('='); - lexpush(); /* push back, for matchtoken() to retrieve again */ - } /* if */ - if (matchtoken('=')) { - /* allow number or symbol */ - if (matchtoken(tSYMBOL)) { - tokeninfo(&val,&str); - insert_alias(sym->name,str); - } else { - exprconst(&val,NULL,NULL); - sym->addr=val; - /* At the moment, I have assumed that this syntax is only valid if - * val < 0. To properly mix "normal" native functions and indexed - * native functions, one should use negative indices anyway. - * Special code for a negative index in sym->addr exists in SC4.C - * (ffcall()) and in SC6.C (the loops for counting the number of native - * variables and for writing them). - */ - } /* if */ - } /* if */ - } /* if */ - - // Don't look for line endings if we're inline. - if (tokid != tMETHODMAP) - needtoken(tTERM); - - /* attach the array to the function symbol */ - if (decl->type.numdim>0) - error(141); - - litidx=0; /* clear the literal pool */ - delete_symbols(&loctab,0,TRUE,TRUE);/* clear local variables queue */ - - return sym; -} - -/* newfunc - begin a function - * - * This routine is called from "parse" and tries to make a function - * out of the following text - * - * Global references: funcstatus,lastst,litidx - * rettype (altered) - * curfunc (altered) - * declared (altered) - * glb_declared (altered) - * sc_alignnext (altered) - */ -static int newfunc(declinfo_t *decl, const int *thistag, int fpublic, int fstatic, int stock, symbol **symp) -{ - symbol *sym; - int argcnt,funcline; - int opererror; - cell cidx,glbdecl; - short filenum; - - assert(litidx==0); /* literal queue should be empty */ - litidx=0; /* clear the literal pool (should already be empty) */ - lastst=0; /* no statement yet */ - cidx=0; /* just to avoid compiler warnings */ - glbdecl=0; - assert(loctab.next==NULL); /* local symbol table should be empty */ - filenum=fcurrent; /* save file number at the start of the declaration */ - - if (symp) - *symp = NULL; - - check_void_decl(decl, FALSE); - - if (decl->opertok) { - check_operatortag(decl->opertok, decl->type.tag, decl->name); - } /* if */ - - /* check whether this is a function or a variable declaration */ - if (!matchtoken('(')) - return FALSE; - /* so it is a function, proceed */ - funcline=fline; /* save line at which the function is defined */ - if (decl->name[0]==PUBLIC_CHAR) { - fpublic=TRUE; /* implicitly public function */ - if (stock) - error(42); /* invalid combination of class specifiers */ - } /* if */ - - if ((sym=fetchfunc(decl->name)) == NULL) - return TRUE; - - // Not a valid function declaration if native. - if (sym->usage & uNATIVE) - return TRUE; - - // If the function has not been prototyed, set its tag. - if (!(sym->usage & uPROTOTYPED)) - sym->tag = decl->type.tag; - - // As long as the function stays undefined, update its address. - if (!(sym->usage & uDEFINE)) - sym->addr = code_idx; - - if (fpublic) - sym->usage|=uPUBLIC; - if (fstatic) - sym->fnumber=filenum; - - if (sym->usage & (uPUBLIC | uFORWARD)) { - if (decl->type.numdim > 0) - error(141); - } - - /* if the function was used before being declared, and it has a tag for the - * result, add a third pass (as second "skimming" parse) because the function - * result may have been used with user-defined operators, which have now - * been incorrectly flagged (as the return tag was unknown at the time of - * the call) - */ - if ((sym->usage & (uPROTOTYPED | uREAD))==uREAD && sym->tag!=0) { - int curstatus=sc_status; - sc_status=statWRITE; /* temporarily set status to WRITE, so the warning isn't blocked */ -#if 0 /* SourceMod - silly, should be removed in first pass, so removed */ - error(208); -#endif - sc_status=curstatus; - sc_reparse=TRUE; /* must add another pass to "initial scan" phase */ - } /* if */ - - /* declare all arguments */ - argcnt = declargs(sym, TRUE, thistag); - opererror = !operatoradjust(decl->opertok, sym, decl->name, decl->type.tag); - if (strcmp(decl->name, uMAINFUNC)==0 || strcmp(decl->name, uENTRYFUNC)==0) { - if (argcnt>0) - error(5); /* "main()" and "entry()" functions may not have any arguments */ - sym->usage|=uREAD; /* "main()" is the program's entry point: always used */ - } /* if */ - - if ((sym->usage & uDEFINE)!=0) - error(21, sym->name); - - /* "declargs()" found the ")"; if a ";" appears after this, it was a - * prototype */ - if (matchtoken(';')) { - if (sym->usage & uPUBLIC) - error(10); - sym->usage|=uFORWARD; - if (!sc_needsemicolon) - error(10); /* old style prototypes used with optional semicolumns */ - delete_symbols(&loctab,0,TRUE,TRUE); /* prototype is done; forget everything */ - return TRUE; - } /* if */ - /* so it is not a prototype, proceed */ - - /* if this is a function that is not referred to (this can only be detected - * in the second stage), shut code generation off */ - if (sc_status==statWRITE && (sym->usage & uREAD)==0 && !fpublic) { - cidx=code_idx; - glbdecl=glb_declared; - - sc_status=statSKIP; - - // If this is a method, output errors even if it's unused. - if (thistag && *thistag != -1) - sc_err_status = TRUE; - } /* if */ - - if ((sym->flags & flgDEPRECATED) != 0 && (sym->usage & uSTOCK) == 0) { - const char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; - error(234, decl->name, ptr); /* deprecated (probably a public function) */ - } /* if */ - begcseg(); - sym->usage|=uDEFINE; /* set the definition flag */ - if (stock) - sym->usage|=uSTOCK; - if (decl->opertok != 0 && opererror) - sym->usage &= ~uDEFINE; - startfunc(sym->name); /* creates stack frame */ - insert_dbgline(funcline); - setline(FALSE); - if (sc_alignnext) { - alignframe(sc_dataalign); - sc_alignnext=FALSE; - } /* if */ - declared=0; /* number of local cells */ - resetstacklist(); - resetheaplist(); - rettype=(sym->usage & uRETVALUE); /* set "return type" variable */ - curfunc=sym; - define_args(); /* add the symbolic info for the function arguments */ - #if !defined SC_LIGHT - if (matchtoken('{')) { - lexpush(); - } else { - // We require '{' for new methods. - if (decl->type.is_new) - needtoken('{'); - - /* Insert a separator so that comments following the statement will not - * be attached to this function; they should be attached to the next - * function. This is not a problem for functions having a compound block, - * because the closing brace is an explicit "end token" for the function. - * With single statement functions, the preprocessor may overread the - * source code before the parser determines an "end of statement". - */ - insert_docstring_separator(); - } /* if */ - #endif - statement(NULL,FALSE); - - if ((rettype & uRETVALUE)!=0) { - sym->usage|=uRETVALUE; - } else { - if (sym->tag == pc_tag_void && - (sym->usage & uFORWARD) && - !decl->type.tag && - !decl->type.is_new) - { - // We got something like: - // forward void X(); - // public X() - // - // Switch our decl type to void. - decl->type.tag = pc_tag_void; - decl->type.tags[0] = pc_tag_void; - } - } - - // Check that return tags match. - if ((sym->usage & uPROTOTYPED) && !compare_tag(sym->tag, decl->type.tag)) { - int old_fline = fline; - fline = sym->lnumber; - error(25); - fline = old_fline; - } - - if (declared!=0) { - /* This happens only in a very special (and useless) case, where a function - * has only a single statement in its body (no compound block) and that - * statement declares a new variable - */ - popstacklist(1); - declared=0; - } /* if */ - if ((lastst!=tRETURN) && (lastst!=tGOTO)){ - ldconst(0,sPRI); - ffret(strcmp(sym->name,uENTRYFUNC)!=0); - if ((sym->usage & uRETVALUE)!=0) { - char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ - funcdisplayname(symname,sym->name); - error(209,symname); /* function should return a value */ - } /* if */ - } /* if */ - endfunc(); - sym->codeaddr=code_idx; - sc_attachdocumentation(sym); /* attach collected documenation to the function */ - if (litidx) { /* if there are literals defined */ - glb_declared+=litidx; - begdseg(); /* flip to DATA segment */ - dumplits(); /* dump literal strings */ - litidx=0; - } /* if */ - testsymbols(&loctab,0,TRUE,TRUE); /* test for unused arguments and labels */ - delete_symbols(&loctab,0,TRUE,TRUE); /* clear local variables queue */ - assert(loctab.next==NULL); - curfunc=NULL; - if (sc_status==statSKIP) { - sc_status=statWRITE; - code_idx=cidx; - glb_declared=glbdecl; - sc_err_status=FALSE; - } /* if */ - if (symp) - *symp = sym; - return TRUE; -} - -static int argcompare(arginfo *a1,arginfo *a2) -{ - int result,level,i; - - result=1; - if (result) - result= a1->ident==a2->ident; /* type/class */ - if (result) - result= a1->usage==a2->usage; /* "const" flag */ - if (result) - result= a1->numtags==a2->numtags; /* tags (number and names) */ - for (i=0; result && inumtags; i++) - result= compare_tag(a1->tags[i], a2->tags[i]); - if (result) - result= a1->numdim==a2->numdim; /* array dimensions & index tags */ - for (level=0; result && levelnumdim; level++) - result= a1->dim[level]==a2->dim[level]; - for (level=0; result && levelnumdim; level++) - result= compare_tag(a1->idxtag[level], a2->idxtag[level]); - if (result) - result= a1->hasdefault==a2->hasdefault; /* availability of default value */ - if (a1->hasdefault) { - if (a1->ident==iREFARRAY) { - if (result) - result= a1->defvalue.array.size==a2->defvalue.array.size; - if (result) - result= a1->defvalue.array.arraysize==a2->defvalue.array.arraysize; - /* ??? should also check contents of the default array (these troubles - * go away in a 2-pass compiler that forbids double declarations, but - * Pawn currently does not forbid them) */ - } else { - if (result) { - if ((a1->hasdefault & uSIZEOF)!=0 || (a1->hasdefault & uTAGOF)!=0 || (a1->hasdefault & uCOUNTOF)!=0) - result= a1->hasdefault==a2->hasdefault - && strcmp(a1->defvalue.size.symname,a2->defvalue.size.symname)==0 - && a1->defvalue.size.level==a2->defvalue.size.level; - else - result= a1->defvalue.val==a2->defvalue.val; - } /* if */ - } /* if */ - if (result) - result= compare_tag(a1->defvalue_tag, a2->defvalue_tag); - } /* if */ - return result; -} - -/* declargs() - * - * This routine adds an entry in the local symbol table for each argument - * found in the argument list. It returns the number of arguments. - */ -static int declargs(symbol *sym, int chkshadow, const int *thistag) -{ - char *ptr; - int argcnt,oldargcnt; - arginfo arg, *arglist; - char name[sNAMEMAX+1]; - int fpublic; - int idx; - - /* if the function is already defined earlier, get the number of arguments - * of the existing definition - */ - oldargcnt=0; - if ((sym->usage & uPROTOTYPED)!=0) - while (sym->dim.arglist[oldargcnt].ident!=0) - oldargcnt++; - argcnt=0; /* zero aruments up to now */ - fpublic = (sym->usage & (uPUBLIC|uSTOCK))!=0; - - if (thistag && *thistag != -1) { - arginfo *argptr; - if ((sym->usage & uPROTOTYPED) == 0) { - // Allocate space for a new argument, then terminate. - sym->dim.arglist = (arginfo *)realloc(sym->dim.arglist, (argcnt + 2) * sizeof(arginfo)); - memset(&sym->dim.arglist[argcnt + 1], 0, sizeof(arginfo)); - - argptr = &sym->dim.arglist[argcnt]; - memset(argptr, 0, sizeof(*argptr)); - strcpy(argptr->name, "this"); - argptr->ident = iVARIABLE; - argptr->tags = (int *)malloc(sizeof(int)); - argptr->tags[0] = *thistag; - argptr->numtags = 1; - argptr->usage = uCONST; - } else { - argptr = &sym->dim.arglist[0]; - } - - symbol *sym = addvariable2( - argptr->name, - (argcnt+3)*sizeof(cell), - argptr->ident, - sLOCAL, - argptr->tags[0], - argptr->dim, - argptr->numdim, - argptr->idxtag, - 0 - ); - sym->usage |= uCONST; - markusage(sym, uREAD); - - argcnt++; - } - - /* the '(' parantheses has already been parsed */ - if (!matchtoken(')')){ - do { /* there are arguments; process them */ - declinfo_t decl; - - parse_decl(&decl, DECLFLAG_ARGUMENT|DECLFLAG_ENUMROOT); - assert(decl.type.numtags > 0); - - check_void_decl(&decl, TRUE); - - if (decl.type.ident == iVARARGS) { - assert(decl.type.numtags > 0); - if ((sym->usage & uPROTOTYPED)==0) { - /* redimension the argument list, add the entry iVARARGS */ - sym->dim.arglist=(arginfo*)realloc(sym->dim.arglist,(argcnt+2)*sizeof(arginfo)); - if (sym->dim.arglist==0) - error(FATAL_ERROR_OOM); /* insufficient memory */ - memset(&sym->dim.arglist[argcnt+1],0,sizeof(arginfo)); /* keep the list terminated */ - sym->dim.arglist[argcnt].ident=iVARARGS; - sym->dim.arglist[argcnt].hasdefault=FALSE; - sym->dim.arglist[argcnt].defvalue.val=0; - sym->dim.arglist[argcnt].defvalue_tag=0; - sym->dim.arglist[argcnt].numtags=decl.type.numtags; - sym->dim.arglist[argcnt].tags=(int*)malloc(decl.type.numtags*sizeof decl.type.tags[0]); - if (sym->dim.arglist[argcnt].tags==NULL) - error(FATAL_ERROR_OOM); /* insufficient memory */ - memcpy(sym->dim.arglist[argcnt].tags,decl.type.tags,decl.type.numtags*sizeof decl.type.tags[0]); - } else { - if (argcnt>oldargcnt || sym->dim.arglist[argcnt].ident!=iVARARGS) - error(25); /* function definition does not match prototype */ - } /* if */ - argcnt++; - continue; - } - - if (argcnt>=sMAXARGS) - error(45); - if (decl.name[0] == PUBLIC_CHAR) - error(56, decl.name); /* function arguments cannot be public */ - - if (decl.type.ident == iARRAY) - decl.type.ident = iREFARRAY; - /* Stack layout: - * base + 0*sizeof(cell) == previous "base" - * base + 1*sizeof(cell) == function return address - * base + 2*sizeof(cell) == number of arguments - * base + 3*sizeof(cell) == first argument of the function - * So the offset of each argument is "(argcnt+3) * sizeof(cell)". - */ - doarg(&decl,(argcnt+3)*sizeof(cell),fpublic,chkshadow,&arg); - - if ((sym->usage & uPUBLIC) && arg.hasdefault) - error(59, decl.name); /* arguments of a public function may not have a default value */ - - if ((sym->usage & uPROTOTYPED)==0) { - /* redimension the argument list, add the entry */ - sym->dim.arglist=(arginfo*)realloc(sym->dim.arglist,(argcnt+2)*sizeof(arginfo)); - if (sym->dim.arglist==0) - error(FATAL_ERROR_OOM); /* insufficient memory */ - memset(&sym->dim.arglist[argcnt+1],0,sizeof(arginfo)); /* keep the list terminated */ - sym->dim.arglist[argcnt]=arg; - } else { - /* check the argument with the earlier definition */ - if (argcnt>oldargcnt || !argcompare(&sym->dim.arglist[argcnt],&arg)) - error(25); /* function definition does not match prototype */ - /* may need to free default array argument and the tag list */ - if (arg.ident==iREFARRAY && arg.hasdefault) - free(arg.defvalue.array.data); - else if ((arg.ident==iVARIABLE - && ((arg.hasdefault & uSIZEOF)!=0 || (arg.hasdefault & uTAGOF)!=0)) || (arg.hasdefault & uCOUNTOF)!=0) - free(arg.defvalue.size.symname); - free(arg.tags); - } /* if */ - argcnt++; - } while (matchtoken(',')); - /* if the next token is not ",", it should be ")" */ - needtoken(')'); - } /* if */ - /* resolve any "sizeof" arguments (now that all arguments are known) */ - assert(sym->dim.arglist!=NULL); - arglist=sym->dim.arglist; - for (idx=0; idx=argcnt) { - error(17,ptr); /* undefined symbol */ - } else { - assert(arglist[idx].defvalue.size.symname!=NULL); - /* check the level against the number of dimensions */ - if (arglist[idx].defvalue.size.level>0 - && arglist[idx].defvalue.size.level>=arglist[altidx].numdim) - error(28,arglist[idx].name); /* invalid subscript */ - /* check the type of the argument whose size to take; for a iVARIABLE - * or a iREFERENCE, this is always 1 (so the code is redundant) - */ - assert(arglist[altidx].ident!=iVARARGS); - if (arglist[altidx].ident!=iREFARRAY - && (((arglist[idx].hasdefault & uSIZEOF)!=0) - || (arglist[idx].hasdefault & uCOUNTOF)!=0)) { - if ((arglist[idx].hasdefault & uTAGOF)!=0) { - error(81,arglist[idx].name); /* cannot take "tagof" an indexed array */ - } else { - assert(arglist[altidx].ident==iVARIABLE || arglist[altidx].ident==iREFERENCE); - error(223,ptr); /* redundant sizeof */ - } /* if */ - } /* if */ - } /* if */ - } /* if */ - } /* for */ - - sym->usage|=uPROTOTYPED; - errorset(sRESET,0); /* reset error flag (clear the "panic mode")*/ - return argcnt; -} - -/* doarg - declare one argument type - * - * this routine is called from "declargs()" and adds an entry in the local - * symbol table for one argument. - * - * "fpublic" indicates whether the function for this argument list is public. - * The arguments themselves are never public. - */ -static void doarg(declinfo_t *decl, int offset, int fpublic, int chkshadow, arginfo *arg) -{ - symbol *argsym; - int slength=0; - typeinfo_t *type = &decl->type; - - // Otherwise we get very weird line number ranges, anything to the current fline. - errorset(sEXPRMARK,0); - - strcpy(arg->name, decl->name); - arg->hasdefault=FALSE; /* preset (most common case) */ - arg->defvalue.val=0; /* clear */ - arg->defvalue_tag=0; - arg->numdim=0; - if (type->ident == iREFARRAY) { - arg->numdim = type->numdim; - memcpy(arg->dim, type->dim, sizeof(int) * type->numdim); - memcpy(arg->idxtag, type->idxtag, sizeof(int) * type->numdim); - assert(type->numtags > 0); - if (type->tags[0] == pc_tag_string) { - slength = arg->dim[arg->numdim - 1]; - arg->dim[arg->numdim - 1] = (type->size + sizeof(cell) - 1) / sizeof(cell); - } - if (matchtoken('=')) { - assert(litidx==0); /* at the start of a function, this is reset */ - /* Check if there is a symbol */ - if (matchtoken(tSYMBOL)) { - symbol *sym; - char *name; - cell val; - tokeninfo(&val,&name); - if ((sym=findglb(name, sGLOBAL)) == NULL) { - error(17, name); /* undefined symbol */ - } else { - arg->hasdefault=TRUE; /* argument as a default value */ - memset(&arg->defvalue, 0, sizeof(arg->defvalue)); - arg->defvalue.array.data=NULL; - arg->defvalue.array.addr=sym->addr; - arg->defvalue_tag=sym->tag; - if (sc_status==statWRITE && (sym->usage & uREAD)==0) { - markusage(sym, uREAD); - } - } - } else { - if (type->is_new && !type->has_postdims && lexpeek('{')) { - // Dynamic array with fixed initializer. - error(160); - } - initials2(type->ident, type->tags[0], &type->size, arg->dim, arg->numdim, type->enumroot, 1, 0); - assert(type->size >= litidx); - /* allocate memory to hold the initial values */ - arg->defvalue.array.data=(cell *)malloc(litidx*sizeof(cell)); - if (arg->defvalue.array.data!=NULL) { - int i; - memcpy(arg->defvalue.array.data,litq,litidx*sizeof(cell)); - arg->hasdefault=TRUE; /* argument has default value */ - arg->defvalue.array.size=litidx; - arg->defvalue.array.addr=-1; - /* calulate size to reserve on the heap */ - arg->defvalue.array.arraysize=1; - for (i=0; inumdim; i++) - arg->defvalue.array.arraysize*=arg->dim[i]; - if (arg->defvalue.array.arraysize < arg->defvalue.array.size) - arg->defvalue.array.arraysize = arg->defvalue.array.size; - } /* if */ - litidx=0; /* reset */ - } - } else { - if (type->is_new && type->has_postdims) { - for (int i = 0; i < type->numdim; i++) { - if (type->dim[i] <= 0) { - // Fixed-array with unknown size. - error(159); - break; - } - } - } - } - } else { - if (matchtoken('=')) { - unsigned char size_tag_token; - assert(type->ident==iVARIABLE || type->ident==iREFERENCE); - arg->hasdefault=TRUE; /* argument has a default value */ - size_tag_token=(unsigned char)(matchtoken(tSIZEOF) ? uSIZEOF : 0); - if (size_tag_token==0) - size_tag_token=(unsigned char)(matchtoken(tTAGOF) ? uTAGOF : 0); - if (size_tag_token==0) - size_tag_token=(unsigned char)(matchtoken(tCELLSOF) ? uCOUNTOF : 0); - if (size_tag_token!=0) { - int paranthese; - if (type->ident==iREFERENCE) - error(66, decl->name); /* argument may not be a reference */ - paranthese=0; - while (matchtoken('(')) - paranthese++; - if (needtoken(tSYMBOL)) { - /* save the name of the argument whose size id to take */ - char *name; - cell val; - tokeninfo(&val,&name); - if ((arg->defvalue.size.symname=duplicatestring(name)) == NULL) - error(FATAL_ERROR_OOM); /* insufficient memory */ - arg->defvalue.size.level=0; - if (size_tag_token==uSIZEOF || size_tag_token==uCOUNTOF) { - while (matchtoken('[')) { - arg->defvalue.size.level+=(short)1; - needtoken(']'); - } /* while */ - } /* if */ - if (type->ident==iVARIABLE) /* make sure we set this only if not a reference */ - arg->hasdefault |= size_tag_token; /* uSIZEOF or uTAGOF */ - } /* if */ - while (paranthese--) - needtoken(')'); - } else { - exprconst(&arg->defvalue.val,&arg->defvalue_tag,NULL); - assert(type->numtags > 0); - matchtag(type->tags[0], arg->defvalue_tag, TRUE); - } /* if */ - } /* if */ - } /* if */ - arg->ident=(char)type->ident; - arg->usage=type->usage; - arg->numtags=type->numtags; - arg->tags=(int*)malloc(type->numtags * sizeof(type->tags[0])); - if (arg->tags==NULL) - error(FATAL_ERROR_OOM); /* insufficient memory */ - memcpy(arg->tags, type->tags, type->numtags * sizeof(type->tags[0])); - argsym=findloc(decl->name); - if (argsym!=NULL) { - error(21, decl->name); /* symbol already defined */ - } else { - if (chkshadow && (argsym=findglb(decl->name,sSTATEVAR))!=NULL && argsym->ident!=iFUNCTN) - error(219, decl->name); /* variable shadows another symbol */ - /* add details of type and address */ - assert(type->numtags > 0); - argsym=addvariable2(decl->name,offset,type->ident,sLOCAL,type->tags[0], - arg->dim,arg->numdim,arg->idxtag,slength); - argsym->compound=0; - if (type->ident==iREFERENCE) - argsym->usage|=uREAD; /* because references are passed back */ - if (fpublic) - argsym->usage|=uREAD; /* arguments of public functions are always "used" */ - if (type->usage & uCONST) - argsym->usage|=uCONST; - } /* if */ - - errorset(sEXPRRELEASE,0); -} - -static int count_referrers(symbol *entry) -{ - int i,count; - - count=0; - for (i=0; inumrefers; i++) - if (entry->refer[i]!=NULL) - count++; - return count; -} - -#if !defined SC_LIGHT -static int find_xmltag(char *source, const char *xmltag, const char *xmlparam, const char *xmlvalue, - char **outer_start,int *outer_length, - const char **inner_start,int *inner_length) -{ - char *ptr; - const char *inner_end; - int xmltag_len,xmlparam_len,xmlvalue_len; - int match; - - assert(source!=NULL); - assert(xmltag!=NULL); - assert(outer_start!=NULL); - assert(outer_length!=NULL); - assert(inner_start!=NULL); - assert(inner_length!=NULL); - - /* both NULL or both non-NULL */ - assert((xmlvalue!=NULL && xmlparam!=NULL) || (xmlvalue==NULL && xmlparam==NULL)); - - xmltag_len=strlen(xmltag); - xmlparam_len= (xmlparam!=NULL) ? strlen(xmlparam) : 0; - xmlvalue_len= (xmlvalue!=NULL) ? strlen(xmlvalue) : 0; - ptr=source; - /* find an opening '<' */ - while ((ptr=strchr(ptr,'<'))!=NULL) { - *outer_start=ptr; /* be optimistic... */ - match=FALSE; /* ...and pessimistic at the same time */ - ptr++; /* skip '<' */ - while (*ptr!='\0' && *ptr<=' ') - ptr++; /* skip white space */ - if (strncmp(ptr,xmltag,xmltag_len)==0 && (*(ptr+xmltag_len)<=' ' || *(ptr+xmltag_len)=='>')) { - /* xml tag found, optionally check the parameter */ - ptr+=xmltag_len; - while (*ptr!='\0' && *ptr<=' ') - ptr++; /* skip white space */ - if (xmlparam!=NULL) { - if (strncmp(ptr,xmlparam,xmlparam_len)==0 && (*(ptr+xmlparam_len)<=' ' || *(ptr+xmlparam_len)=='=')) { - ptr+=xmlparam_len; - while (*ptr!='\0' && *ptr<=' ') - ptr++; /* skip white space */ - if (*ptr=='=') { - ptr++; /* skip '=' */ - while (*ptr!='\0' && *ptr<=' ') - ptr++; /* skip white space */ - if (*ptr=='"' || *ptr=='\'') - ptr++; /* skip " or ' */ - assert(xmlvalue!=NULL); - if (strncmp(ptr,xmlvalue,xmlvalue_len)==0 - && (*(ptr+xmlvalue_len)<=' ' - || *(ptr+xmlvalue_len)=='>' - || *(ptr+xmlvalue_len)=='"' - || *(ptr+xmlvalue_len)=='\'')) - match=TRUE; /* found it */ - } /* if */ - } /* if */ - } else { - match=TRUE; /* don't check the parameter */ - } /* if */ - } /* if */ - if (match) { - /* now find the end of the opening tag */ - while (*ptr!='\0' && *ptr!='>') - ptr++; - if (*ptr=='>') - ptr++; - while (*ptr!='\0' && *ptr<=' ') - ptr++; /* skip white space */ - *inner_start=ptr; - /* find the start of the closing tag (assume no nesting) */ - while ((ptr=strchr(ptr,'<'))!=NULL) { - inner_end=ptr; - ptr++; /* skip '<' */ - while (*ptr!='\0' && *ptr<=' ') - ptr++; /* skip white space */ - if (*ptr=='/') { - ptr++; /* skip / */ - while (*ptr!='\0' && *ptr<=' ') - ptr++; /* skip white space */ - if (strncmp(ptr,xmltag,xmltag_len)==0 && (*(ptr+xmltag_len)<=' ' || *(ptr+xmltag_len)=='>')) { - /* find the end of the closing tag */ - while (*ptr!='\0' && *ptr!='>') - ptr++; - if (*ptr=='>') - ptr++; - /* set the lengths of the inner and outer segment */ - assert(*inner_start!=NULL); - *inner_length=(int)(inner_end-*inner_start); - assert(*outer_start!=NULL); - *outer_length=(int)(ptr-*outer_start); - break; /* break out of the loop */ - } /* if */ - } /* if */ - } /* while */ - return TRUE; - } /* if */ - } /* while */ - return FALSE; /* not found */ -} - -static char *xmlencode(char *dest,char *source) -{ - char temp[2*sNAMEMAX+20],*ptr; - - /* replace < by < and such; normally, such a symbol occurs at most once in - * a symbol name (e.g. "operator<") - */ - ptr=temp; - while (*source!='\0') { - switch (*source) { - case '<': - strcpy(ptr,"<"); - ptr+=4; - break; - case '>': - strcpy(ptr,">"); - ptr+=4; - break; - case '&': - strcpy(ptr,"&"); - ptr+=5; - break; - default: - *ptr++=*source; - } /* switch */ - source++; - } /* while */ - *ptr='\0'; - strcpy(dest,temp); - return dest; -} - -static void make_report(symbol *root,FILE *log,char *sourcefile) -{ - char symname[_MAX_PATH]; - int i,arg; - symbol *sym,*ref; - constvalue *tagsym; - constvalue *enumroot; - char *ptr; - - /* adapt the installation directory */ - strcpy(symname,sc_rootpath); - #if DIRSEP_CHAR=='\\' - while ((ptr=strchr(symname,':'))!=NULL) - *ptr='|'; - while ((ptr=strchr(symname,DIRSEP_CHAR))!=NULL) - *ptr='/'; - #endif - - /* the XML header */ - fprintf(log,"\n"); - fprintf(log,"\n",symname); - fprintf(log,"\n",sourcefile); - ptr=strrchr(sourcefile,DIRSEP_CHAR); - if (ptr!=NULL) - ptr++; - else - ptr=sourcefile; - fprintf(log,"\t\n\t\t%s\n\t\n",ptr); - - /* attach the global documentation, if any */ - if (sc_documentation!=NULL) { - fprintf(log,"\n\t\n"); - fprintf(log,"\t\n\t\t"); - fputs(sc_documentation,log); - fprintf(log,"\n\t\n\n"); - } /* if */ - - /* use multiple passes to print constants variables and functions in - * separate sections - */ - fprintf(log,"\t\n"); - - fprintf(log,"\n\t\t\n"); - for (sym=root->next; sym!=NULL; sym=sym->next) { - if (sym->parent!=NULL) - continue; /* hierarchical data type */ - assert(sym->ident==iCONSTEXPR || sym->ident==iVARIABLE - || sym->ident==iARRAY || sym->ident==iFUNCTN); - if (sym->ident!=iCONSTEXPR || (sym->usage & uENUMROOT)==0) - continue; - if ((sym->usage & uREAD)==0) - continue; - fprintf(log,"\t\t\n",funcdisplayname(symname,sym->name),sym->addr); - if (sym->tag!=0) { - tagsym=find_tag_byval(sym->tag); - assert(tagsym!=NULL); - fprintf(log,"\t\t\t\n",tagsym->name); - } /* if */ - /* browse through all fields */ - if ((enumroot=sym->dim.enumlist)!=NULL) { - enumroot=enumroot->next; /* skip root */ - while (enumroot!=NULL) { - fprintf(log,"\t\t\t\n",funcdisplayname(symname,enumroot->name),enumroot->value); - /* find the constant with this name and get the tag */ - ref=findglb(enumroot->name,sGLOBAL); - if (ref!=NULL) { - if (ref->x.tags.index!=0) { - tagsym=find_tag_byval(ref->x.tags.index); - assert(tagsym!=NULL); - fprintf(log,"\t\t\t\t\n",tagsym->name); - } /* if */ - if (ref->dim.array.length!=1) - fprintf(log,"\t\t\t\t\n",(long)ref->dim.array.length); - } /* if */ - fprintf(log,"\t\t\t\n"); - enumroot=enumroot->next; - } /* while */ - } /* if */ - assert(sym->refer!=NULL); - for (i=0; inumrefers; i++) { - if ((ref=sym->refer[i])!=NULL) - fprintf(log,"\t\t\t\n",xmlencode(symname,funcdisplayname(symname,ref->name))); - } /* for */ - if (sym->documentation!=NULL) - fprintf(log,"\t\t\t%s\n",sym->documentation); - fprintf(log,"\t\t\n"); - } /* for */ - - fprintf(log,"\n\t\t\n"); - for (sym=root->next; sym!=NULL; sym=sym->next) { - if (sym->parent!=NULL) - continue; /* hierarchical data type */ - assert(sym->ident==iCONSTEXPR || sym->ident==iVARIABLE - || sym->ident==iARRAY || sym->ident==iFUNCTN); - if (sym->ident!=iCONSTEXPR) - continue; - if ((sym->usage & uREAD)==0 || (sym->usage & (uENUMFIELD | uENUMROOT))!=0) - continue; - fprintf(log,"\t\t\n",funcdisplayname(symname,sym->name),sym->addr); - if (sym->tag!=0) { - tagsym=find_tag_byval(sym->tag); - assert(tagsym!=NULL); - fprintf(log,"\t\t\t\n",tagsym->name); - } /* if */ - assert(sym->refer!=NULL); - for (i=0; inumrefers; i++) { - if ((ref=sym->refer[i])!=NULL) - fprintf(log,"\t\t\t\n",xmlencode(symname,funcdisplayname(symname,ref->name))); - } /* for */ - if (sym->documentation!=NULL) - fprintf(log,"\t\t\t%s\n",sym->documentation); - fprintf(log,"\t\t\n"); - } /* for */ - - fprintf(log,"\n\t\t\n"); - for (sym=root->next; sym!=NULL; sym=sym->next) { - if (sym->parent!=NULL) - continue; /* hierarchical data type */ - if (sym->ident!=iVARIABLE && sym->ident!=iARRAY) - continue; - fprintf(log,"\t\t\n",funcdisplayname(symname,sym->name)); - if (sym->tag!=0) { - tagsym=find_tag_byval(sym->tag); - assert(tagsym!=NULL); - fprintf(log,"\t\t\t\n",tagsym->name); - } /* if */ - assert(sym->refer!=NULL); - if ((sym->usage & uPUBLIC)!=0) - fprintf(log,"\t\t\t\n"); - for (i=0; inumrefers; i++) { - if ((ref=sym->refer[i])!=NULL) - fprintf(log,"\t\t\t\n",xmlencode(symname,funcdisplayname(symname,ref->name))); - } /* for */ - if (sym->documentation!=NULL) - fprintf(log,"\t\t\t%s\n",sym->documentation); - fprintf(log,"\t\t\n"); - } /* for */ - - fprintf(log,"\n\t\t\n"); - for (sym=root->next; sym!=NULL; sym=sym->next) { - if (sym->parent!=NULL) - continue; /* hierarchical data type */ - if (sym->ident!=iFUNCTN) - continue; - if ((sym->usage & (uREAD | uNATIVE))==uNATIVE) - continue; /* unused native function */ - funcdisplayname(symname,sym->name); - xmlencode(symname,symname); - fprintf(log,"\t\tdim.arglist!=NULL); - for (arg=0; sym->dim.arglist[arg].ident!=0; arg++) { - int dim; - if (arg>0) - fprintf(log,", "); - switch (sym->dim.arglist[arg].ident) { - case iVARIABLE: - fprintf(log,"%s",sym->dim.arglist[arg].name); - break; - case iREFERENCE: - fprintf(log,"&%s",sym->dim.arglist[arg].name); - break; - case iREFARRAY: - fprintf(log,"%s",sym->dim.arglist[arg].name); - for (dim=0; dimdim.arglist[arg].numdim;dim++) - fprintf(log,"[]"); - break; - case iVARARGS: - fprintf(log,"..."); - break; - } /* switch */ - } /* for */ - /* ??? should also print an "array return" size */ - fprintf(log,")\">\n"); - if (sym->tag!=0) { - tagsym=find_tag_byval(sym->tag); - assert(tagsym!=NULL); - fprintf(log,"\t\t\t\n",tagsym->name); - } /* if */ - /* check whether this function is called from the outside */ - if ((sym->usage & uNATIVE)!=0) - fprintf(log,"\t\t\t\n"); - if ((sym->usage & uPUBLIC)!=0) - fprintf(log,"\t\t\t\n"); - if (strcmp(sym->name,uMAINFUNC)==0 || strcmp(sym->name,uENTRYFUNC)==0) - fprintf(log,"\t\t\t\n"); - if ((sym->usage & uNATIVE)==0) - fprintf(log,"\t\t\t\n",(long)sym->x.stacksize); - if (sym->states!=NULL) { - constvalue *stlist=sym->states->next; - assert(stlist!=NULL); /* there should be at least one state item */ - while (stlist!=NULL && stlist->index==-1) - stlist=stlist->next; - assert(stlist!=NULL); /* state id should be found */ - i=state_getfsa(stlist->index); - assert(i>=0); /* automaton 0 exists */ - stlist=automaton_findid(i); - assert(stlist!=NULL); /* automaton should be found */ - fprintf(log,"\t\t\t\n", strlen(stlist->name)>0 ? stlist->name : "(anonymous)"); - //??? dump state decision table - } /* if */ - assert(sym->refer!=NULL); - for (i=0; inumrefers; i++) - if ((ref=sym->refer[i])!=NULL) - fprintf(log,"\t\t\t\n",xmlencode(symname,funcdisplayname(symname,ref->name))); - /* print all symbols that are required for this function to compile */ - for (ref=root->next; ref!=NULL; ref=ref->next) { - if (ref==sym) - continue; - for (i=0; inumrefers; i++) - if (ref->refer[i]==sym) - fprintf(log,"\t\t\t\n",xmlencode(symname,funcdisplayname(symname,ref->name))); - } /* for */ - /* print parameter list, with tag & const information, plus descriptions */ - assert(sym->dim.arglist!=NULL); - for (arg=0; sym->dim.arglist[arg].ident!=0; arg++) { - int dim,paraminfo; - char *outer_start; - const char *inner_start; - int outer_length,inner_length; - if (sym->dim.arglist[arg].ident==iVARARGS) - fprintf(log,"\t\t\t\n"); - else - fprintf(log,"\t\t\t\n",sym->dim.arglist[arg].name); - /* print the tag name(s) for each parameter */ - assert(sym->dim.arglist[arg].numtags>0); - assert(sym->dim.arglist[arg].tags!=NULL); - paraminfo=(sym->dim.arglist[arg].numtags>1 || sym->dim.arglist[arg].tags[0]!=0) - || sym->dim.arglist[arg].ident==iREFERENCE - || sym->dim.arglist[arg].ident==iREFARRAY; - if (paraminfo) - fprintf(log,"\t\t\t\t"); - if (sym->dim.arglist[arg].numtags>1 || sym->dim.arglist[arg].tags[0]!=0) { - assert(paraminfo); - if (sym->dim.arglist[arg].numtags>1) - fprintf(log," {"); - for (i=0; idim.arglist[arg].numtags; i++) { - if (i>0) - fprintf(log,","); - tagsym=find_tag_byval(sym->dim.arglist[arg].tags[i]); - assert(tagsym!=NULL); - fprintf(log,"%s",tagsym->name); - } /* for */ - if (sym->dim.arglist[arg].numtags>1) - fprintf(log,"}"); - } /* if */ - switch (sym->dim.arglist[arg].ident) { - case iREFERENCE: - fprintf(log," &"); - break; - case iREFARRAY: - fprintf(log," "); - for (dim=0; dimdim.arglist[arg].numdim; dim++) { - if (sym->dim.arglist[arg].dim[dim]==0) { - fprintf(log,"[]"); - } else { - //??? find index tag - fprintf(log,"[%d]",sym->dim.arglist[arg].dim[dim]); - } /* if */ - } /* for */ - break; - } /* switch */ - if (paraminfo) - fprintf(log," \n"); - /* print the user description of the parameter (parse through - * sym->documentation) - */ - if (sym->documentation!=NULL - && find_xmltag(sym->documentation, "param", "name", sym->dim.arglist[arg].name, - &outer_start, &outer_length, &inner_start, &inner_length)) - { - fprintf(log,"\t\t\t\t%.*s\n",inner_length,inner_start); - /* delete from documentation string */ - char *tail=outer_start+outer_length; - memmove(outer_start,tail,strlen(tail)+1); - } /* if */ - fprintf(log,"\t\t\t\n"); - } /* for */ - if (sym->documentation!=NULL) - fprintf(log,"\t\t\t%s\n",sym->documentation); - fprintf(log,"\t\t\n"); - } /* for */ - - fprintf(log,"\n\t\n"); - fprintf(log,"\n"); -} -#endif - -/* Every symbol has a referrer list, that contains the functions that use - * the symbol. Now, if function "apple" is accessed by functions "banana" and - * "citron", but neither function "banana" nor "citron" are used by anyone - * else, then, by inference, function "apple" is not used either. - */ -static void reduce_referrers(symbol *root) -{ - int i,restart; - symbol *sym,*ref; - - do { - restart=0; - for (sym=root->next; sym!=NULL; sym=sym->next) { - if (sym->parent!=NULL) - continue; /* hierarchical data type */ - if (sym->ident==iFUNCTN - && (sym->usage & uNATIVE)==0 - && (sym->usage & uPUBLIC)==0 && strcmp(sym->name,uMAINFUNC)!=0 && strcmp(sym->name,uENTRYFUNC)!=0 - && count_referrers(sym)==0) - { - sym->usage&=~(uREAD | uWRITTEN); /* erase usage bits if there is no referrer */ - /* find all symbols that are referred by this symbol */ - for (ref=root->next; ref!=NULL; ref=ref->next) { - if (ref->parent!=NULL) - continue; /* hierarchical data type */ - assert(ref->refer!=NULL); - for (i=0; inumrefers && ref->refer[i]!=sym; i++) - /* nothing */; - if (inumrefers) { - assert(ref->refer[i]==sym); - ref->refer[i]=NULL; - restart++; - } /* if */ - } /* for */ - } else if ((sym->ident==iVARIABLE || sym->ident==iARRAY) - && (sym->usage & uPUBLIC)==0 - && sym->parent==NULL - && count_referrers(sym)==0) - { - sym->usage&=~(uREAD | uWRITTEN); /* erase usage bits if there is no referrer */ - } /* if */ - } /* for */ - /* after removing a symbol, check whether more can be removed */ - } while (restart>0); -} - -#if !defined SC_LIGHT -static long max_stacksize_recurse(symbol *sourcesym,symbol *sym,long basesize,int *pubfuncparams,int *recursion) -{ - long size,maxsize; - int i; - - assert(sym!=NULL); - assert(sym->ident==iFUNCTN); - assert((sym->usage & uNATIVE)==0); - assert(recursion!=NULL); - - maxsize=sym->x.stacksize; - for (i=0; inumrefers; i++) { - if (sym->refer[i]!=NULL) { - assert(sym->refer[i]->ident==iFUNCTN); - assert((sym->refer[i]->usage & uNATIVE)==0); /* a native function cannot refer to a user-function */ - if (sym->refer[i]==sourcesym) { /* recursion detection */ - *recursion=1; - break; /* recursion was detected, quit loop */ - } /* if */ - size=max_stacksize_recurse(sourcesym,sym->refer[i],sym->x.stacksize,pubfuncparams,recursion); - if (maxsizeusage & uPUBLIC)!=0) { - /* Find out how many parameters a public function has, then see if this - * is bigger than some maximum - */ - arginfo *arg=sym->dim.arglist; - int count=0; - assert(arg!=0); - while (arg->ident!=0) { - count++; - arg++; - } /* while */ - assert(pubfuncparams!=0); - if (count>*pubfuncparams) - *pubfuncparams=count; - } /* if */ - - return maxsize+basesize; -} - -static symbol *save_symbol; - -static long max_stacksize(symbol *root,int *recursion) -{ - /* Loop over all non-native functions. For each function, loop - * over all of its referrers, accumulating the stack requirements. - * Detect (indirect) recursion with a "mark-and-sweep" algorithm. - * I (mis-)use the "compound" field of the symbol structure for - * the marker, as this field is unused for functions. - * - * Note that the stack is shared with the heap. A host application - * may "eat" cells from the heap as well, through amx_Allot(). The - * stack requirements are thus only an estimate. - */ - long size,maxsize; - int maxparams; - symbol *sym; - - assert(root!=NULL); - assert(recursion!=NULL); - #if !defined NDEBUG - for (sym=root->next; sym!=NULL; sym=sym->next) - if (sym->ident==iFUNCTN) - assert(sym->compound==0); - #endif - - maxsize=0; - maxparams=0; - *recursion=0; /* assume no recursion */ - for (sym=root->next; sym!=NULL; sym=sym->next) { - /* drop out if this is not a user-implemented function */ - if (sym->ident!=iFUNCTN || (sym->usage & uNATIVE)!=0) - continue; - /* accumulate stack size for this symbol */ - save_symbol = sym; - size=max_stacksize_recurse(sym,sym,0L,&maxparams,recursion); - assert(size>=0); - if (maxsizenext; - while (sym!=NULL && sym->compound>=level) { - switch (sym->ident) { - case iLABEL: - if (testlabs) { - if ((sym->usage & uDEFINE)==0) { - error(19,sym->name); /* not a label: ... */ - } else if ((sym->usage & uREAD)==0) { - errorset(sSETPOS,sym->lnumber); - error(203,sym->name); /* symbol isn't used: ... */ - } /* if */ - } /* if */ - break; - case iFUNCTN: - if ((sym->usage & (uDEFINE | uREAD | uNATIVE | uSTOCK | uPUBLIC))==uDEFINE) { - funcdisplayname(symname,sym->name); - if (strlen(symname)>0) - error(203,symname); /* symbol isn't used ... (and not public/native/stock) */ - } /* if */ - if ((sym->usage & uPUBLIC)!=0 || strcmp(sym->name,uMAINFUNC)==0) - entry=TRUE; /* there is an entry point */ - /* also mark the function to the debug information */ - if (((sym->usage & uREAD)!=0 || (sym->usage & uPUBLIC)!=0) && (sym->usage & uNATIVE)==0) - insert_dbgsymbol(sym); - break; - case iCONSTEXPR: - if (testconst && (sym->usage & uREAD)==0) { - errorset(sSETPOS,sym->lnumber); - error(203,sym->name); /* symbol isn't used: ... */ - } /* if */ - break; - case iMETHODMAP: - // Ignore usage on methodmaps. - break; - default: - /* a variable */ - if (sym->parent!=NULL) - break; /* hierarchical data type */ - if ((sym->usage & (uWRITTEN | uREAD | uSTOCK))==0) { - errorset(sSETPOS,sym->lnumber); - error(203,sym->name); /* symbol isn't used (and not stock) */ - } else if ((sym->usage & (uREAD | uSTOCK | uPUBLIC))==0) { - errorset(sSETPOS,sym->lnumber); - error(204,sym->name); /* value assigned to symbol is never used */ -#if 0 // ??? not sure whether it is a good idea to force people use "const" - } else if ((sym->usage & (uWRITTEN | uPUBLIC | uCONST))==0 && sym->ident==iREFARRAY) { - errorset(sSETPOS,sym->lnumber); - error(214,sym->name); /* make array argument "const" */ -#endif - } /* if */ - /* also mark the variable (local or global) to the debug information */ - if ((sym->usage & (uWRITTEN | uREAD))!=0 && (sym->usage & uNATIVE)==0) - insert_dbgsymbol(sym); - } /* if */ - sym=sym->next; - } /* while */ - - return entry; -} - -static cell calc_array_datasize(symbol *sym, cell *offset) -{ - cell length; - - assert(sym!=NULL); - assert(sym->ident==iARRAY || sym->ident==iREFARRAY); - length=sym->dim.array.length; - if (sym->dim.array.level > 0) { - cell sublength=calc_array_datasize(finddepend(sym),offset); - if (offset!=NULL) - *offset=length*(*offset+sizeof(cell)); - if (sublength>0) - length*=length*sublength; - else - length=0; - } else { - if (offset!=NULL) - *offset=0; - } /* if */ - return length; -} - -static void destructsymbols(symbol *root,int level) -{ - cell offset=0; - int savepri=FALSE; - symbol *sym=root->next; - while (sym!=NULL && get_actual_compound(sym)>=level) { - if (sym->ident==iVARIABLE || sym->ident==iARRAY) { - char symbolname[16]; - symbol *opsym; - cell elements; - /* check that the '~' operator is defined for this tag */ - operator_symname(symbolname,"~",sym->tag,0,1,0); - if ((opsym=findglb(symbolname,sGLOBAL))!=NULL) { - /* save PRI, in case of a return statment */ - if (!savepri) { - pushreg(sPRI); /* right-hand operand is in PRI */ - savepri=TRUE; - } /* if */ - /* if the variable is an array, get the number of elements */ - if (sym->ident==iARRAY) { - elements=calc_array_datasize(sym,&offset); - /* "elements" can be zero when the variable is declared like - * new mytag: myvar[2][] = { {1, 2}, {3, 4} } - * one should declare all dimensions! - */ - if (elements==0) - error(46,sym->name); /* array size is unknown */ - } else { - elements=1; - offset=0; - } /* if */ - pushval(elements); - /* call the '~' operator */ - address(sym,sPRI); - addconst(offset); /* add offset to array data to the address */ - pushreg(sPRI); - pushval(2 /* *sizeof(cell)*/ );/* 2 parameters */ - assert(opsym->ident==iFUNCTN); - ffcall(opsym,NULL,1); - if (sc_status!=statSKIP) - markusage(opsym,uREAD); /* do not mark as "used" when this call itself is skipped */ - if ((opsym->usage & uNATIVE)!=0 && opsym->x.lib!=NULL) - opsym->x.lib->value += 1; /* increment "usage count" of the library */ - } /* if */ - } /* if */ - sym=sym->next; - } /* while */ - /* restore PRI, if it was saved */ - if (savepri) - popreg(sPRI); -} - -static constvalue *insert_constval(constvalue *prev,constvalue *next,const char *name,cell val, - int index) -{ - constvalue *cur; - - if ((cur=(constvalue*)malloc(sizeof(constvalue)))==NULL) - error(FATAL_ERROR_OOM); /* insufficient memory (fatal error) */ - memset(cur,0,sizeof(constvalue)); - if (name!=NULL) { - assert(strlen(name)<=sNAMEMAX); - strcpy(cur->name,name); - } /* if */ - cur->value=val; - cur->index=index; - cur->next=next; - prev->next=cur; - return cur; -} - -constvalue *append_constval(constvalue *table,const char *name,cell val,int index) -{ - constvalue *cur,*prev; - - /* find the end of the constant table */ - for (prev=table, cur=table->next; cur!=NULL; prev=cur, cur=cur->next) - /* nothing */; - return insert_constval(prev,NULL,name,val,index); -} - -constvalue *find_constval(constvalue *table,char *name,int index) -{ - constvalue *ptr = table->next; - - while (ptr!=NULL) { - if (strcmp(name,ptr->name)==0 && ptr->index==index) - return ptr; - ptr=ptr->next; - } /* while */ - return NULL; -} - -static constvalue *find_constval_byval(constvalue *table,cell val) -{ - constvalue *ptr = table->next; - - while (ptr!=NULL) { - if (ptr->value==val) - return ptr; - ptr=ptr->next; - } /* while */ - return NULL; -} - -#if 0 /* never used */ -static int delete_constval(constvalue *table,char *name) -{ - constvalue *prev = table; - constvalue *cur = prev->next; - - while (cur!=NULL) { - if (strcmp(name,cur->name)==0) { - prev->next=cur->next; - free(cur); - return TRUE; - } /* if */ - prev=cur; - cur=cur->next; - } /* while */ - return FALSE; -} -#endif - -void delete_consttable(constvalue *table) -{ - constvalue *cur=table->next, *next; - - while (cur!=NULL) { - next=cur->next; - free(cur); - cur=next; - } /* while */ - memset(table,0,sizeof(constvalue)); -} - -/* add_constant - * - * Adds a symbol to the symbol table. Returns NULL on failure. - */ -symbol *add_constant(const char *name,cell val,int vclass,int tag) -{ - symbol *sym; - - /* Test whether a global or local symbol with the same name exists. Since - * constants are stored in the symbols table, this also finds previously - * defind constants. */ - sym=findglb(name,sSTATEVAR); - if (!sym) - sym=findloc(name); - if (sym) { - int redef=0; - if (sym->ident!=iCONSTEXPR) - redef=1; /* redefinition a function/variable to a constant is not allowed */ - if ((sym->usage & uENUMFIELD)!=0) { - /* enum field, special case if it has a different tag and the new symbol is also an enum field */ - constvalue *tagid; - symbol *tagsym; - if (sym->tag==tag) - redef=1; /* enumeration field is redefined (same tag) */ - tagid=find_tag_byval(tag); - if (tagid==NULL) { - redef=1; /* new constant does not have a tag */ - } else { - tagsym=findconst(tagid->name,NULL); - if (tagsym==NULL || (tagsym->usage & uENUMROOT)==0) - redef=1; /* new constant is not an enumeration field */ - } /* if */ - /* in this particular case (enumeration field that is part of a different - * enum, and non-conflicting with plain constants) we want to be able to - * redefine it - */ - if (!redef) - goto redef_enumfield; - } else if (!compare_tag(sym->tag, tag)) { - redef=1; /* redefinition of a constant (non-enum) to a different tag is not allowed */ - } /* if */ - if (redef) { - error(21,name); /* symbol already defined */ - return NULL; - } else if (sym->addr!=val) { - error(201,name); /* redefinition of constant (different value) */ - sym->addr=val; /* set new value */ - } /* if */ - /* silently ignore redefinitions of constants with the same value & tag */ - return sym; - } /* if */ - - /* constant doesn't exist yet (or is allowed to be redefined) */ -redef_enumfield: - sym=addsym(name,val,iCONSTEXPR,vclass,tag,uDEFINE); - assert(sym!=NULL); /* fatal error 103 must be given on error */ - if (sc_status == statIDLE) - sym->usage |= uPREDEF; - return sym; -} - -/* statement - The Statement Parser - * - * This routine is called whenever the parser needs to know what statement - * it encounters (i.e. whenever program syntax requires a statement). - */ -static void statement(int *lastindent,int allow_decl) -{ - int tok,save; - cell val; - char *st; - - if (!freading) { - error(36); /* empty statement */ - return; - } /* if */ - errorset(sRESET,0); - - tok=lex(&val,&st); - if (tok!='{') { - insert_dbgline(fline); - setline(TRUE); - } /* if */ - /* lex() has set stmtindent */ - if (lastindent!=NULL && tok!=tLABEL) { - if (*lastindent>=0 && *lastindent!=stmtindent && !indent_nowarn && sc_tabsize>0) - error(217); /* loose indentation */ - *lastindent=stmtindent; - indent_nowarn=FALSE; /* if warning was blocked, re-enable it */ - } /* if */ - - if (tok == tSYMBOL) { - // We reaaaally don't have enough lookahead for this, so we cheat and try - // to determine whether this is probably a declaration. - int is_decl = FALSE; - if (matchtoken('[')) { - if (lexpeek(']')) - is_decl = TRUE; - lexpush(); - } else if (lexpeek(tSYMBOL)) { - is_decl = TRUE; - } - - if (is_decl) { - if (!allow_decl) { - error(3); - return; - } - lexpush(); - autozero = TRUE; - lastst = tNEW; - declloc(tNEWDECL); - return; - } - } - - switch (tok) { - case 0: - /* nothing */ - break; - case tINT: - case tVOID: - case tCHAR: - case tOBJECT: - lexpush(); - // Fall-through. - case tDECL: - case tSTATIC: - case tNEW: - if (!allow_decl) { - error(3); - break; - } - autozero = (tok != tDECL); - lastst = (tok == tDECL) ? tDECL : tNEW; - declloc(tok); - break; - case tDELETE: - dodelete(); - lastst=tDELETE; - break; - case '{': - case tBEGIN: - save=fline; - if (!matchtoken('}')) { /* {} is the empty statement */ - compound(save==fline,tok); - } else { - lastst = tEMPTYBLOCK; - } - /* lastst (for "last statement") does not change - you're not my father, don't tell me what to do */ - break; - case ';': - error(36); /* empty statement */ - break; - case tIF: - lastst=doif(); - break; - case tWHILE: - lastst=dowhile(); - break; - case tDO: - lastst=dodo(); - break; - case tFOR: - lastst=dofor(); - break; - case tSWITCH: - doswitch(); - lastst=tSWITCH; - break; - case tCASE: - case tDEFAULT: - error(14); /* not in switch */ - break; - case tGOTO: - dogoto(); - lastst=tGOTO; - break; - case tLABEL: - dolabel(); - lastst=tLABEL; - break; - case tRETURN: - doreturn(); - lastst=tRETURN; - break; - case tBREAK: - dobreak(); - lastst=tBREAK; - break; - case tCONTINUE: - docont(); - lastst=tCONTINUE; - break; - case tEXIT: - doexit(); - lastst=tEXIT; - break; - case tASSERT: - doassert(); - lastst=tASSERT; - break; - case tSLEEP: - dosleep(); - lastst=tSLEEP; - break; - case tCONST: - decl_const(sLOCAL); - break; - case tENUM: - decl_enum(sLOCAL); - break; - default: /* non-empty expression */ - sc_allowproccall=optproccall; - lexpush(); /* analyze token later */ - doexpr(TRUE,TRUE,TRUE,TRUE,NULL,NULL,FALSE); - needtoken(tTERM); - lastst=tEXPR; - sc_allowproccall=FALSE; - } /* switch */ -} - -static void compound(int stmt_sameline,int starttok) -{ - int indent=-1; - cell save_decl=declared; - int count_stmt=0; - int block_start=fline; /* save line where the compound block started */ - int endtok; - - pushstacklist(); - pushheaplist(); - /* if there is more text on this line, we should adjust the statement indent */ - if (stmt_sameline) { - int i; - const unsigned char *p=lptr; - /* go back to the opening brace */ - while (*p!=starttok) { - assert(p>pline); - p--; - } /* while */ - assert(*p==starttok); /* it should be found */ - /* go forward, skipping white-space */ - p++; - while (*p<=' ' && *p!='\0') - p++; - assert(*p!='\0'); /* a token should be found */ - stmtindent=0; - for (i=0; i<(int)(p-pline); i++) - if (pline[i]=='\t' && sc_tabsize>0) - stmtindent += (int)(sc_tabsize - (stmtindent+sc_tabsize) % sc_tabsize); - else - stmtindent++; - } /* if */ - - endtok=(starttok=='{') ? '}' : tEND; - nestlevel+=1; /* increase compound statement level */ - while (matchtoken(endtok)==0){/* repeat until compound statement is closed */ - if (!freading){ - error(30,block_start); /* compound block not closed at end of file */ - break; - } else { - if (count_stmt>0 && (lastst==tRETURN || lastst==tBREAK || lastst==tCONTINUE || lastst==tENDLESS)) - error(225); /* unreachable code */ - statement(&indent,TRUE); /* do a statement */ - count_stmt++; - } /* if */ - } /* while */ - if (lastst!=tRETURN) - destructsymbols(&loctab,nestlevel); - if (lastst!=tRETURN && lastst!=tGOTO) { - popheaplist(); - popstacklist(1); - } else { - popheaplist(); - popstacklist(0); - } - testsymbols(&loctab,nestlevel,FALSE,TRUE); /* look for unused block locals */ - declared=save_decl; - delete_symbols(&loctab,nestlevel,FALSE,TRUE); /* erase local symbols, but - * retain block local labels - * (within the function) */ - nestlevel-=1; /* decrease compound statement level */ -} - -/* doexpr - * - * Global references: stgidx (referred to only) - */ -static int doexpr(int comma,int chkeffect,int allowarray,int mark_endexpr, - int *tag,symbol **symptr,int chkfuncresult) -{ - return doexpr2(comma,chkeffect,allowarray,mark_endexpr,tag,symptr,chkfuncresult,NULL); -} - -/* doexpr2 - * - * Global references: stgidx (referred to only) - */ -static int doexpr2(int comma,int chkeffect,int allowarray,int mark_endexpr, - int *tag,symbol **symptr,int chkfuncresult,value *lval) -{ - int index,ident; - int localstaging=FALSE; - cell val; - - if (!staging) { - stgset(TRUE); /* start stage-buffering */ - localstaging=TRUE; - assert(stgidx==0); - } /* if */ - index=stgidx; - errorset(sEXPRMARK,0); - do { - /* on second round through, mark the end of the previous expression */ - if (index!=stgidx) - markexpr(sEXPR,NULL,0); - sideeffect=FALSE; - ident=expression(&val,tag,symptr,chkfuncresult,lval); - if (!allowarray && (ident==iARRAY || ident==iREFARRAY)) - error(33,"-unknown-"); /* array must be indexed */ - if (chkeffect && !sideeffect) - error(215); /* expression has no effect */ - sc_allowproccall=FALSE; /* cannot use "procedure call" syntax anymore */ - } while (comma && matchtoken(',')); /* more? */ - if (mark_endexpr) - markexpr(sEXPR,NULL,0); /* optionally, mark the end of the expression */ - errorset(sEXPRRELEASE,0); - if (localstaging) { - stgout(index); - stgset(FALSE); /* stop staging */ - } /* if */ - return ident; -} - -/* exprconst - */ -int exprconst(cell *val,int *tag,symbol **symptr) -{ - int ident,index; - cell cidx; - - stgset(TRUE); /* start stage-buffering */ - stgget(&index,&cidx); /* mark position in code generator */ - errorset(sEXPRMARK,0); - ident=expression(val,tag,symptr,FALSE,NULL); - stgdel(index,cidx); /* scratch generated code */ - stgset(FALSE); /* stop stage-buffering */ - if (ident!=iCONSTEXPR) { - error(8); /* must be constant expression */ - if (val!=NULL) - *val=0; - if (tag!=NULL) - *tag=0; - if (symptr!=NULL) - *symptr=NULL; - } /* if */ - errorset(sEXPRRELEASE,0); - return (ident==iCONSTEXPR); -} - -/* test - * - * In the case a "simple assignment" operator ("=") is used within a test, - * the warning "possibly unintended assignment" is displayed. This routine - * sets the global variable "sc_intest" to true, it is restored upon termination. - * In the case the assignment was intended, use parentheses around the - * expression to avoid the warning; primary() sets "sc_intest" to 0. - * - * Global references: sc_intest (altered, but restored upon termination) - */ -static int test(int label,int parens,int invert) -{ - int index,tok; - cell cidx; - int ident,tag; - int endtok; - cell constval; - symbol *sym; - int localstaging=FALSE; - - if (!staging) { - stgset(TRUE); /* start staging */ - localstaging=TRUE; - #if !defined NDEBUG - stgget(&index,&cidx); /* should start at zero if started locally */ - assert(index==0); - #endif - } /* if */ - - PUSHSTK_I(sc_intest); - sc_intest=TRUE; - endtok=0; - if (parens!=TEST_PLAIN) { - if (matchtoken('(')) - endtok=')'; - else if (parens==TEST_THEN) - endtok=tTHEN; - else if (parens==TEST_DO) - endtok=tDO; - } /* if */ - do { - stgget(&index,&cidx); /* mark position (of last expression) in - * code generator */ - ident=expression(&constval,&tag,&sym,TRUE,NULL); - tok=matchtoken(','); - if (tok) - markexpr(sEXPR,NULL,0); - } while (tok); /* do */ - if (endtok!=0) - needtoken(endtok); - if (ident==iARRAY || ident==iREFARRAY) { - const char *ptr=sym->name; - error(33,ptr); /* array must be indexed */ - } /* if */ - if (ident==iCONSTEXPR) { /* constant expression */ - int testtype=0; - sc_intest=(short)POPSTK_I();/* restore stack */ - stgdel(index,cidx); - if (constval) { /* code always executed */ - error(206); /* redundant test: always non-zero */ - testtype=tENDLESS; - } else { - error(205); /* redundant code: never executed */ - jumplabel(label); - } /* if */ - if (localstaging) { - stgout(0); /* write "jumplabel" code */ - stgset(FALSE); /* stop staging */ - } /* if */ - return testtype; - } /* if */ - if (tag!=0 && tag!=pc_tag_bool) { - if (check_userop(lneg,tag,0,1,NULL,&tag)) - invert= !invert; /* user-defined ! operator inverted result */ - } - if (invert) - jmp_ne0(label); /* jump to label if true (different from 0) */ - else - jmp_eq0(label); /* jump to label if false (equal to 0) */ - markexpr(sEXPR,NULL,0); /* end expression (give optimizer a chance) */ - sc_intest=(short)POPSTK_I(); /* double typecast to avoid warning with Microsoft C */ - if (localstaging) { - stgout(0); /* output queue from the very beginning (see - * assert() when localstaging is set to TRUE) */ - stgset(FALSE); /* stop staging */ - } /* if */ - return 0; -} - -static int doif(void) -{ - int flab1,flab2; - int ifindent; - int lastst_true; - - ifindent=stmtindent; /* save the indent of the "if" instruction */ - flab1=getlabel(); /* get label number for false branch */ - test(flab1,TEST_THEN,FALSE); /* get expression, branch to flab1 if false */ - statement(NULL,FALSE); /* if true, do a statement */ - if (!matchtoken(tELSE)) { /* if...else ? */ - setlabel(flab1); /* no, simple if..., print false label */ - } else { - lastst_true=lastst; /* save last statement of the "true" branch */ - /* to avoid the "dangling else" error, we want a warning if the "else" - * has a lower indent than the matching "if" */ - if (stmtindent0) - error(217); /* loose indentation */ - flab2=getlabel(); - if ((lastst!=tRETURN) && (lastst!=tGOTO)) - jumplabel(flab2); /* "true" branch jumps around "else" clause, unless the "true" branch statement already jumped */ - setlabel(flab1); /* print false label */ - statement(NULL,FALSE); /* do "else" clause */ - setlabel(flab2); /* print true label */ - /* if both the "true" branch and the "false" branch ended with the same - * kind of statement, set the last statement id to that kind, rather than - * to the generic tIF; this allows for better "unreachable code" checking - */ - if (lastst==lastst_true) - return lastst; - } /* if */ - return tIF; -} - -static int dowhile(void) -{ - int wq[wqSIZE]; /* allocate local queue */ - int save_endlessloop,retcode; - - save_endlessloop=endlessloop; - addwhile(wq); /* add entry to queue for "break" */ - setlabel(wq[wqLOOP]); /* loop label */ - /* The debugger uses the "break" opcode to be able to "break" out of - * a loop. To make sure that each loop has a break opcode, even for the - * tiniest loop, set it below the top of the loop - */ - setline(TRUE); - endlessloop=test(wq[wqEXIT],TEST_DO,FALSE);/* branch to wq[wqEXIT] if false */ - statement(NULL,FALSE); /* if so, do a statement */ - jumplabel(wq[wqLOOP]); /* and loop to "while" start */ - setlabel(wq[wqEXIT]); /* exit label */ - delwhile(); /* delete queue entry */ - - retcode=endlessloop ? tENDLESS : tWHILE; - endlessloop=save_endlessloop; - return retcode; -} - -/* - * Note that "continue" will in this case not jump to the top of the loop, but - * to the end: just before the TRUE-or-FALSE testing code. - */ -static int dodo(void) -{ - int wq[wqSIZE],top; - int save_endlessloop,retcode; - - save_endlessloop=endlessloop; - addwhile(wq); /* see "dowhile" for more info */ - top=getlabel(); /* make a label first */ - setlabel(top); /* loop label */ - statement(NULL,FALSE); - needtoken(tWHILE); - setlabel(wq[wqLOOP]); /* "continue" always jumps to WQLOOP. */ - setline(TRUE); - endlessloop=test(wq[wqEXIT],TEST_OPT,FALSE); - jumplabel(top); - setlabel(wq[wqEXIT]); - delwhile(); - needtoken(tTERM); - - retcode=endlessloop ? tENDLESS : tDO; - endlessloop=save_endlessloop; - return retcode; -} - -static int dofor(void) -{ - int wq[wqSIZE],skiplab; - cell save_decl; - int save_nestlevel,save_endlessloop; - int index,endtok; - int *ptr; - - save_decl=declared; - save_nestlevel=nestlevel; - save_endlessloop=endlessloop; - pushstacklist(); - - addwhile(wq); - skiplab=getlabel(); - endtok= matchtoken('(') ? ')' : tDO; - if (matchtoken(';')==0) { - /* new variable declarations are allowed here */ - token_t tok; - - switch (lextok(&tok)) { - case tINT: - case tCHAR: - case tOBJECT: - case tVOID: - lexpush(); - // Fallthrough. - case tNEW: - /* The variable in expr1 of the for loop is at a - * 'compound statement' level of it own. - */ - nestlevel++; - autozero=1; - declloc(tok.id); /* declare local variable */ - break; - case tSYMBOL: - { - // See comment in statement() near tSYMBOL. - int is_decl = FALSE; - if (matchtoken('[')) { - if (lexpeek(']')) - is_decl = TRUE; - lexpush(); - } else if (lexpeek(tSYMBOL)) { - is_decl = TRUE; - } - - if (is_decl) { - lexpush(); - nestlevel++; - autozero=1; - declloc(tSYMBOL); - break; - } - - // Fall-through to default! - } - default: - lexpush(); - doexpr(TRUE,TRUE,TRUE,TRUE,NULL,NULL,FALSE); /* expression 1 */ - needtoken(';'); - break; - } - } /* if */ - /* Adjust the "declared" field in the "while queue", in case that - * local variables were declared in the first expression of the - * "for" loop. These are deleted in separately, so a "break" or a "continue" - * must ignore these fields. - */ - ptr=readwhile(); - assert(ptr!=NULL); - /*ptr[wqBRK]=(int)declared; - *ptr[wqCONT]=(int)declared; - */ - ptr[wqBRK] = stackusage->list_id; - ptr[wqCONT] = stackusage->list_id; - jumplabel(skiplab); /* skip expression 3 1st time */ - setlabel(wq[wqLOOP]); /* "continue" goes to this label: expr3 */ - setline(TRUE); - /* Expressions 2 and 3 are reversed in the generated code: expression 3 - * precedes expression 2. When parsing, the code is buffered and marks for - * the start of each expression are insterted in the buffer. - */ - assert(!staging); - stgset(TRUE); /* start staging */ - assert(stgidx==0); - index=stgidx; - stgmark(sSTARTREORDER); - stgmark((char)(sEXPRSTART+0)); /* mark start of 2nd expression in stage */ - setlabel(skiplab); /* jump to this point after 1st expression */ - if (matchtoken(';')) { - endlessloop=1; - } else { - endlessloop=test(wq[wqEXIT],TEST_PLAIN,FALSE);/* expression 2 (jump to wq[wqEXIT] if false) */ - needtoken(';'); - } /* if */ - stgmark((char)(sEXPRSTART+1)); /* mark start of 3th expression in stage */ - if (!matchtoken(endtok)) { - doexpr(TRUE,TRUE,TRUE,TRUE,NULL,NULL,FALSE); /* expression 3 */ - needtoken(endtok); - } /* if */ - stgmark(sENDREORDER); /* mark end of reversed evaluation */ - stgout(index); - stgset(FALSE); /* stop staging */ - statement(NULL,FALSE); - jumplabel(wq[wqLOOP]); - setlabel(wq[wqEXIT]); - delwhile(); - - assert(nestlevel>=save_nestlevel); - if (nestlevel>save_nestlevel) { - /* Clean up the space and the symbol table for the local - * variable in "expr1". - */ - destructsymbols(&loctab,nestlevel); - popstacklist(1); - testsymbols(&loctab,nestlevel,FALSE,TRUE); /* look for unused block locals */ - declared=save_decl; - delete_symbols(&loctab,nestlevel,FALSE,TRUE); - nestlevel=save_nestlevel; /* reset 'compound statement' nesting level */ - } else { - popstacklist(0); - } /* if */ - - index=endlessloop ? tENDLESS : tFOR; - endlessloop=save_endlessloop; - return index; -} - -/* The switch statement is incompatible with its C sibling: - * 1. the cases are not drop through - * 2. only one instruction may appear below each case, use a compound - * instruction to execute multiple instructions - * 3. the "case" keyword accepts a comma separated list of values to - * match - * - * SWITCH param - * PRI = expression result - * param = table offset (code segment) - * - */ -static void doswitch(void) -{ - int lbl_table,lbl_exit,lbl_case; - int swdefault,casecount; - int tok,endtok; - cell val; - char *str; - constvalue caselist = { NULL, "", 0, 0}; /* case list starts empty */ - constvalue *cse,*csp; - char labelname[sNAMEMAX+1]; - - endtok= matchtoken('(') ? ')' : tDO; - doexpr(TRUE,FALSE,FALSE,FALSE,NULL,NULL,TRUE);/* evaluate switch expression */ - needtoken(endtok); - /* generate the code for the switch statement, the label is the address - * of the case table (to be generated later). - */ - lbl_table=getlabel(); - lbl_case=0; /* just to avoid a compiler warning */ - ffswitch(lbl_table); - - if (matchtoken(tBEGIN)) { - endtok=tEND; - } else { - endtok='}'; - needtoken('{'); - } /* if */ - lbl_exit=getlabel(); /* get label number for jumping out of switch */ - swdefault=FALSE; - casecount=0; - do { - tok=lex(&val,&str); /* read in (new) token */ - switch (tok) { - case tCASE: - if (swdefault!=FALSE) - error(15); /* "default" case must be last in switch statement */ - lbl_case=getlabel(); - PUSHSTK_I(sc_allowtags); - sc_allowtags=FALSE; /* do not allow tagnames here */ - do { - casecount++; - - /* ??? enforce/document that, in a switch, a statement cannot start - * with a label. Then, you can search for: - * * the first semicolon (marks the end of a statement) - * * an opening brace (marks the start of a compound statement) - * and search for the right-most colon before that statement - * Now, by replacing the ':' by a special COLON token, you can - * parse all expressions until that special token. - */ - - exprconst(&val,NULL,NULL); - /* Search the insertion point (the table is kept in sorted order, so - * that advanced abstract machines can sift the case table with a - * binary search). Check for duplicate case values at the same time. - */ - for (csp=&caselist, cse=caselist.next; - cse!=NULL && cse->valuenext) - /* nothing */; - if (cse!=NULL && cse->value==val) - error(40,val); /* duplicate "case" label */ - /* Since the label is stored as a string in the "constvalue", the - * size of an identifier must be at least 8, as there are 8 - * hexadecimal digits in a 32-bit number. - */ - #if sNAMEMAX < 8 - #error Length of identifier (sNAMEMAX) too small. - #endif - assert(csp!=NULL); - assert(csp->next==cse); - insert_constval(csp,cse,itoh(lbl_case),val,0); - if (matchtoken(tDBLDOT)) { - error(1, ":", ".."); - } /* if */ - } while (matchtoken(',')); - needtoken(':'); /* ':' ends the case */ - sc_allowtags=(short)POPSTK_I(); /* reset */ - setlabel(lbl_case); - statement(NULL,FALSE); - jumplabel(lbl_exit); - break; - case tDEFAULT: - if (swdefault!=FALSE) - error(16); /* multiple defaults in switch */ - lbl_case=getlabel(); - setlabel(lbl_case); - needtoken(':'); - swdefault=TRUE; - statement(NULL,FALSE); - /* Jump to lbl_exit, even thouh this is the last clause in the - * switch, because the jump table is generated between the last - * clause of the switch and the exit label. - */ - jumplabel(lbl_exit); - break; - default: - if (tok!=endtok) { - error(2); - indent_nowarn=TRUE; /* disable this check */ - tok=endtok; /* break out of the loop after an error */ - } /* if */ - } /* switch */ - } while (tok!=endtok); - - #if !defined NDEBUG - /* verify that the case table is sorted (unfortunatly, duplicates can - * occur; there really shouldn't be duplicate cases, but the compiler - * may not crash or drop into an assertion for a user error). */ - for (cse=caselist.next; cse!=NULL && cse->next!=NULL; cse=cse->next) - assert(cse->value <= cse->next->value); - #endif - /* generate the table here, before lbl_exit (general jump target) */ - setlabel(lbl_table); - assert(swdefault==FALSE || swdefault==TRUE); - if (swdefault==FALSE) { - /* store lbl_exit as the "none-matched" label in the switch table */ - strcpy(labelname,itoh(lbl_exit)); - } else { - /* lbl_case holds the label of the "default" clause */ - strcpy(labelname,itoh(lbl_case)); - } /* if */ - ffcase(casecount,labelname,TRUE); - /* generate the rest of the table */ - for (cse=caselist.next; cse!=NULL; cse=cse->next) - ffcase(cse->value,cse->name,FALSE); - - setlabel(lbl_exit); - delete_consttable(&caselist); /* clear list of case labels */ -} - -static void doassert(void) -{ - int flab1,index; - cell cidx; - - if ((sc_debug & sCHKBOUNDS)!=0) { - flab1=getlabel(); /* get label number for "OK" branch */ - test(flab1,TEST_PLAIN,TRUE);/* get expression and branch to flab1 if true */ - insert_dbgline(fline); /* make sure we can find the correct line number */ - ffabort(xASSERTION); - setlabel(flab1); - } else { - stgset(TRUE); /* start staging */ - stgget(&index,&cidx); /* mark position in code generator */ - do { - expression(NULL,NULL,NULL,FALSE,NULL); - stgdel(index,cidx); /* just scrap the code */ - } while (matchtoken(',')); - stgset(FALSE); /* stop staging */ - } /* if */ - needtoken(tTERM); -} - -static void dogoto(void) -{ - char *st; - cell val; - symbol *sym; - - /* if we were inside an endless loop, assume that we jump out of it */ - endlessloop=0; - - error(4, "goto"); - - if (lex(&val,&st)==tSYMBOL) { - sym=fetchlab(st); - jumplabel((int)sym->addr); - sym->usage|=uREAD; /* set "uREAD" bit */ - // ??? if the label is defined (check sym->usage & uDEFINE), check - // sym->compound (nesting level of the label) against nestlevel; - // if sym->compound < nestlevel, call the destructor operator - } else { - error(20,st); /* illegal symbol name */ - } /* if */ - needtoken(tTERM); -} - -static void dolabel(void) -{ - char *st; - cell val; - symbol *sym; - - tokeninfo(&val,&st); /* retrieve label name again */ - if (find_constval(&tagname_tab,st,0)!=NULL) - error(221,st); /* label name shadows tagname */ - sym=fetchlab(st); - setlabel((int)sym->addr); - /* since one can jump around variable declarations or out of compound - * blocks, the stack must be manually adjusted - */ - //:TODO: This is actually generated, egads! - //We have to support this and LCTRL/SCTRL - setstk(-declared*sizeof(cell)); - sym->usage|=uDEFINE; /* label is now defined */ -} - -/* fetchlab - * - * Finds a label from the (local) symbol table or adds one to it. - * Labels are local in scope. - * - * Note: The "_usage" bit is set to zero. The routines that call "fetchlab()" - * must set this bit accordingly. - */ -static symbol *fetchlab(char *name) -{ - symbol *sym; - - sym=findloc(name); /* labels are local in scope */ - if (sym){ - if (sym->ident!=iLABEL) - error(19,sym->name); /* not a label: ... */ - } else { - sym=addsym(name,getlabel(),iLABEL,sLOCAL,0,0); - assert(sym!=NULL); /* fatal error 103 must be given on error */ - sym->x.declared=(int)declared; - sym->compound=nestlevel; - } /* if */ - return sym; -} - -static int is_variadic(symbol *sym) -{ - assert(sym->ident==iFUNCTN); - arginfo *arg = sym->dim.arglist; - while (arg->ident) { - if (arg->ident == iVARARGS) - return TRUE; - arg++; - } - return FALSE; -} - -/* doreturn - * - * Global references: rettype (altered) - */ -static void doreturn(void) -{ - int tag,ident; - int level; - symbol *sym,*sub; - - if (!matchtoken(tTERM)) { - /* "return " */ - if ((rettype & uRETNONE)!=0) - error(78); /* mix "return;" and "return value;" */ - ident=doexpr(TRUE,FALSE,TRUE,FALSE,&tag,&sym,TRUE); - needtoken(tTERM); - if (ident==iARRAY && sym==NULL) { - /* returning a literal string is not supported (it must be a variable) */ - error(39); - ident=iCONSTEXPR; /* avoid handling an "array" case */ - } /* if */ - /* see if this function already has a sub type (an array attached) */ - sub=finddepend(curfunc); - assert(sub==NULL || sub->ident==iREFARRAY); - if ((rettype & uRETVALUE)!=0) { - int retarray=(ident==iARRAY || ident==iREFARRAY); - /* there was an earlier "return" statement in this function */ - if ((sub==NULL && retarray) || (sub!=NULL && !retarray)) - error(79); /* mixing "return array;" and "return value;" */ - if (retarray && (curfunc->usage & uPUBLIC)!=0) - error(90,curfunc->name); /* public function may not return array */ - } /* if */ - rettype|=uRETVALUE; /* function returns a value */ - /* check tagname with function tagname */ - assert(curfunc!=NULL); - if (!matchtag_string(ident, tag)) - matchtag(curfunc->tag,tag,TRUE); - if (ident==iARRAY || ident==iREFARRAY) { - int dim[sDIMEN_MAX], numdim = 0; - cell arraysize; - assert(sym!=NULL); - if (sub!=NULL) { - assert(sub->ident==iREFARRAY); - /* this function has an array attached already; check that the current - * "return" statement returns exactly the same array - */ - level=sym->dim.array.level; - if (sub->dim.array.level!=level) { - error(48); /* array dimensions must match */ - } else { - for (numdim=0; numdim<=level; numdim++) { - dim[numdim]=(int)sub->dim.array.length; - if (sym->dim.array.length!=dim[numdim]) - error(47); /* array sizes must match */ - if (numdimdim.array.level; - for (numdim=0; numdim<=level; numdim++) { - dim[numdim]=(int)sub->dim.array.length; - idxtag[numdim]=sub->x.tags.index; - if (numdimname); - } /* for */ - if (sym->tag==pc_tag_string && numdim!=0) - slength=dim[numdim-1]; - /* the address of the array is stored in a hidden parameter; the address - * of this parameter is 1 + the number of parameters (times the size of - * a cell) + the size of the stack frame and the return address - * base + 0*sizeof(cell) == previous "base" - * base + 1*sizeof(cell) == function return address - * base + 2*sizeof(cell) == number of arguments - * base + 3*sizeof(cell) == first argument of the function - * ... - * base + ((n-1)+3)*sizeof(cell) == last argument of the function - * base + (n+3)*sizeof(cell) == hidden parameter with array address - */ - assert(curfunc!=NULL); - assert(curfunc->dim.arglist!=NULL); - for (argcount=0; curfunc->dim.arglist[argcount].ident!=0; argcount++) - /* nothing */; - sub=addvariable2(curfunc->name,(argcount+3)*sizeof(cell),iREFARRAY,sGLOBAL,curfunc->tag,dim,numdim,idxtag,slength); - sub->parent=curfunc; - } /* if */ - /* 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 - * the end of the expression/statement, see expression() in SC3.C) - */ - if (is_variadic(curfunc)) { - load_hidden_arg(); - } else { - address(sub,sALT); /* ALT = destination */ - } - arraysize=calc_arraysize(dim,numdim,0); - memcopy(arraysize*sizeof(cell)); /* source already in PRI */ - /* moveto1(); is not necessary, callfunction() does a popreg() */ - } /* if */ - } else { - /* this return statement contains no expression */ - ldconst(0,sPRI); - if ((rettype & uRETVALUE)!=0) { - char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ - assert(curfunc!=NULL); - funcdisplayname(symname,curfunc->name); - error(209,symname); /* function should return a value */ - } /* if */ - rettype|=uRETNONE; /* function does not return anything */ - } /* if */ - destructsymbols(&loctab,0); /* call destructor for *all* locals */ - genheapfree(-1); - genstackfree(-1); /* free everything on the stack */ - ffret(strcmp(curfunc->name,uENTRYFUNC)!=0); -} - -static void dobreak(void) -{ - int *ptr; - - endlessloop=0; /* if we were inside an endless loop, we just jumped out */ - ptr=readwhile(); /* readwhile() gives an error if not in loop */ - needtoken(tTERM); - if (ptr==NULL) - return; - destructsymbols(&loctab,nestlevel); - genstackfree(ptr[wqBRK]); - jumplabel(ptr[wqEXIT]); -} - -static void docont(void) -{ - int *ptr; - - ptr=readwhile(); /* readwhile() gives an error if not in loop */ - needtoken(tTERM); - if (ptr==NULL) - return; - destructsymbols(&loctab,nestlevel); - genstackfree(ptr[wqCONT]); - genheapfree(ptr[wqCONT]); - jumplabel(ptr[wqLOOP]); -} - -static void doexit(void) -{ - int tag=0; - - if (matchtoken(tTERM)==0){ - doexpr(TRUE,FALSE,FALSE,TRUE,&tag,NULL,TRUE); - needtoken(tTERM); - } else { - ldconst(0,sPRI); - } /* if */ - ldconst(tag,sALT); - destructsymbols(&loctab,0); /* call destructor for *all* locals */ - ffabort(xEXIT); -} - -static void dosleep(void) -{ - int tag=0; - - if (matchtoken(tTERM)==0){ - doexpr(TRUE,FALSE,FALSE,TRUE,&tag,NULL,TRUE); - needtoken(tTERM); - } else { - ldconst(0,sPRI); - } /* if */ - ldconst(tag,sALT); - ffabort(xSLEEP); - - /* for stack usage checking, mark the use of the sleep instruction */ - pc_memflags |= suSLEEP_INSTR; -} - -static void dostate(void) -{ - char name[sNAMEMAX+1]; - constvalue *automaton; - constvalue *state; - constvalue *stlist; - int flabel; - symbol *sym; - #if !defined SC_LIGHT - int length,index,listid,listindex,stateindex; - char *doc; - #endif - - /* check for an optional condition */ - if (matchtoken('(')) { - flabel=getlabel(); /* get label number for "false" branch */ - pc_docexpr=TRUE; /* attach expression as a documentation string */ - test(flabel,TEST_PLAIN,FALSE);/* get expression, branch to flabel if false */ - pc_docexpr=FALSE; - needtoken(')'); - } else { - flabel=-1; - } /* if */ - - if (!sc_getstateid(&automaton,&state)) { - delete_autolisttable(); - return; - } /* if */ - needtoken(tTERM); - - /* store the new state id */ - assert(state!=NULL); - ldconst(state->value,sPRI); - assert(automaton!=NULL); - assert((automaton->index==0 && automaton->name[0]=='\0') || automaton->index>0); - storereg(automaton->value,sPRI); - - /* find the optional entry() function for the state */ - sym=findglb(uENTRYFUNC,sGLOBAL); - if (sc_status==statWRITE && sym!=NULL && sym->ident==iFUNCTN && sym->states!=NULL) { - for (stlist=sym->states->next; stlist!=NULL; stlist=stlist->next) { - assert(strlen(stlist->name)!=0); - if (state_getfsa(stlist->index)==automaton->index && state_inlist(stlist->index,(int)state->value)) - break; /* found! */ - } /* for */ - assert(stlist==NULL || state_inlist(stlist->index,state->value)); - if (stlist!=NULL) { - /* the label to jump to is in stlist->name */ - ffcall(sym,stlist->name,0); - } /* if */ - } /* if */ - - if (flabel>=0) - setlabel(flabel); /* condition was false, jump around the state switch */ - - #if !defined SC_LIGHT - /* mark for documentation */ - if (sc_status==statFIRST) { - char *str; - /* get the last list id attached to the function, this contains the source states */ - assert(curfunc!=NULL); - if (curfunc->states!=NULL) { - stlist=curfunc->states->next; - assert(stlist!=NULL); - while (stlist->next!=NULL) - stlist=stlist->next; - listid=stlist->index; - } else { - listid=-1; - } /* if */ - listindex=0; - length=strlen(name)+70; /* +70 for the fixed part "\n" */ - /* see if there are any condition strings to attach */ - for (index=0; (str=get_autolist(index))!=NULL; index++) - length+=strlen(str); - if ((doc=(char*)malloc(length*sizeof(char)))!=NULL) { - do { - sprintf(doc,"=0) { - /* get the source state */ - stateindex=state_listitem(listid,listindex); - state=state_findid(stateindex); - assert(state!=NULL); - sprintf(doc+strlen(doc)," source=\"%s\"",state->name); - } /* if */ - if (get_autolist(0)!=NULL) { - /* add the condition */ - strcat(doc," condition=\""); - for (index=0; (str=get_autolist(index))!=NULL; index++) { - /* remove the ')' token that may be appended before detecting that the expression has ended */ - if (*str!=')' || *(str+1)!='\0' || get_autolist(index+1)!=NULL) - strcat(doc,str); - } /* for */ - strcat(doc,"\""); - } /* if */ - strcat(doc,"/>\n"); - insert_docstring(doc); - } while (listid>=0 && ++listindexlist_id; /* stack pointer (for "break") */ - ptr[wqCONT]=stackusage->list_id; /* for "continue", possibly adjusted later */ - ptr[wqLOOP]=getlabel(); - ptr[wqEXIT]=getlabel(); - if (wqptr>=(wq+wqTABSZ-wqSIZE)) - error(FATAL_ERROR_ALLOC_OVERFLOW,"loop table"); /* loop table overflow (too many active loops)*/ - k=0; - while (kwq) - wqptr-=wqSIZE; -} - -static int *readwhile(void) -{ - if (wqptr<=wq){ - error(24); /* out of context */ - return NULL; - } else { - return (wqptr-wqSIZE); - } /* if */ -} - -bool typeinfo_t::isCharArray() const -{ - return numdim == 1 && tag == pc_tag_string; -} diff --git a/sourcepawn/compiler/sc2.cpp b/sourcepawn/compiler/sc2.cpp deleted file mode 100644 index b2856877..00000000 --- a/sourcepawn/compiler/sc2.cpp +++ /dev/null @@ -1,3274 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -/* Pawn compiler - File input, preprocessing and lexical analysis functions - * - * Copyright (c) ITB CompuPhase, 1997-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include -#include -#include -#include -#include -#include "lstring.h" -#include "sc.h" -#include "tokenbuffer.h" -#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ - #include -#endif -#include "sp_symhash.h" - -#if defined FORTIFY - #include -#endif - -/* flags for litchar() */ -#define RAWMODE 0x1 -#define UTF8MODE 0x2 -#define ISPACKED 0x4 -static cell litchar(const unsigned char **lptr,int flags); -static symbol *find_symbol(const symbol *root,const char *name,int fnumber,int automaton,int *cmptag); - -static void substallpatterns(unsigned char *line,int buffersize); -static int match(const char *st,int end); -static int alpha(char c); - -#define SKIPMODE 1 /* bit field in "#if" stack */ -#define PARSEMODE 2 /* bit field in "#if" stack */ -#define HANDLED_ELSE 4 /* bit field in "#if" stack */ -#define SKIPPING (skiplevel>0 && (ifstack[skiplevel-1] & SKIPMODE)==SKIPMODE) - -static short icomment; /* currently in multiline comment? */ -static char ifstack[sCOMP_STACK]; /* "#if" stack */ -static short iflevel; /* nesting level if #if/#else/#endif */ -static short skiplevel; /* level at which we started skipping (including nested #if .. #endif) */ -static unsigned char term_expr[] = ""; -static int listline=-1; /* "current line" for the list file */ - -#if defined DARWIN -static double pow10(double d) -{ - return pow(10, d); -} -#endif - -static bool sLiteralQueueDisabled = false; - -AutoDisableLiteralQueue::AutoDisableLiteralQueue() - : prev_value_(sLiteralQueueDisabled) -{ - sLiteralQueueDisabled = true; -} - -AutoDisableLiteralQueue::~AutoDisableLiteralQueue() -{ - sLiteralQueueDisabled = prev_value_; -} - -/* pushstk & popstk - * - * Uses a LIFO stack to store information. The stack is used by doinclude(), - * doswitch() (to hold the state of "swactive") and some other routines. - * - * Porting note: I made the bold assumption that an integer will not be - * larger than a pointer (it may be smaller). That is, the stack element - * is typedef'ed as a pointer type, but I also store integers on it. See - * SC.H for "stkitem" - * - * Global references: stack,stkidx,stktop (private to pushstk(), popstk() - * and clearstk()) - */ -static stkitem *stack=NULL; -static int stkidx=0,stktop=0; - -void pushstk(stkitem val) -{ - assert(stkidx<=stktop); - if (stkidx==stktop) { - stkitem *newstack; - int newsize= (stktop==0) ? 16 : 2*stktop; - /* try to resize the stack */ - assert(newsize>stktop); - newstack=(stkitem*)malloc(newsize*sizeof(stkitem)); - if (newstack==NULL) - error(FATAL_ERROR_ALLOC_OVERFLOW,"parser stack"); - /* swap the stacks */ - memcpy(newstack,stack,stkidx*sizeof(stkitem)); - if (stack!=NULL) - free(stack); - stack=newstack; - stktop=newsize; - } /* if */ - assert(stkidx'); /* termination character */ - lptr++; - while (*lptr<=' ' && *lptr!='\0') /* skip whitespace after quote */ - lptr++; - } else { - c='\0'; - } /* if */ - - i=0; - while (*lptr!=c && *lptr!='\0' && i0 && name[i-1]<=' ') - i--; /* strip trailing whitespace */ - assert(i>=0 && i'),TRUE); - if (!result && !silent) - error(FATAL_ERROR_READ,name); -} - -/* readline - * - * Reads in a new line from the input file pointed to by "inpf". readline() - * concatenates lines that end with a \ with the next line. If no more data - * can be read from the file, readline() attempts to pop off the previous file - * from the stack. If that fails too, it sets "freading" to 0. - * - * Global references: inpf,fline,inpfname,freading,icomment (altered) - */ -static void readline(unsigned char *line) -{ - int i,num,cont; - unsigned char *ptr; - - if (lptr==term_expr) - return; - num=sLINEMAX; - cont=FALSE; - do { - if (inpf==NULL || pc_eofsrc(inpf)) { - if (cont) - error(49); /* invalid line continuation */ - if (inpf!=NULL && inpf!=inpf_org) - pc_closesrc(inpf); - i=POPSTK_I(); - if (i==-1) { /* All's done; popstk() returns "stack is empty" */ - freading=FALSE; - *line='\0'; - /* when there is nothing more to read, the #if/#else stack should - * be empty and we should not be in a comment - */ - assert(iflevel>=0); - if (iflevel>0) - error(1,"#endif","-end of file-"); - else if (icomment!=0) - error(1,"*/","-end of file-"); - return; - } /* if */ - fline=i; - fcurrent=(short)POPSTK_I(); - icomment=(short)POPSTK_I(); - sc_is_utf8=(short)POPSTK_I(); - iflevel=(short)POPSTK_I(); - skiplevel=iflevel; /* this condition held before including the file */ - assert(!SKIPPING); /* idem ditto */ - curlibrary=(constvalue *)POPSTK_P(); - free(inpfname); /* return memory allocated for the include file name */ - inpfname=(char *)POPSTK_P(); - inpf=POPSTK_P(); - insert_dbgfile(inpfname); - setfiledirect(inpfname); - listline=-1; /* force a #line directive when changing the file */ - } /* if */ - - if (pc_readsrc(inpf,line,num)==NULL) { - *line='\0'; /* delete line */ - cont=FALSE; - } else { - /* check whether to erase leading spaces */ - if (cont) { - unsigned char *ptr=line; - while (*ptr<=' ' && *ptr!='\0') - ptr++; - if (ptr!=line) - memmove(line,ptr,strlen((char*)ptr)+1); - } /* if */ - cont=FALSE; - /* check whether a full line was read */ - if (strchr((char*)line,'\n')==NULL && !pc_eofsrc(inpf)) - error(75); /* line too long */ - /* check if the next line must be concatenated to this line */ - if ((ptr=(unsigned char*)strchr((char*)line,'\n'))==NULL) - ptr=(unsigned char*)strchr((char*)line,'\r'); - if (ptr!=NULL && ptr>line) { - assert(*(ptr+1)=='\0'); /* '\n' or '\r' should be last in the string */ - while (ptr>line && *ptr<=' ') - ptr--; /* skip trailing whitespace */ - if (*ptr=='\\') { - cont=TRUE; - /* set '\a' at the position of '\\' to make it possible to check - * for a line continuation in a single line comment (error 49) - */ - *ptr++='\a'; - *ptr='\0'; /* erase '\n' (and any trailing whitespace) */ - } /* if */ - } /* if */ - num-=strlen((char*)line); - line+=strlen((char*)line); - } /* if */ - fline+=1; - } while (num>=0 && cont); -} - -/* stripcom - * - * Replaces all comments from the line by space characters. It updates - * a global variable ("icomment") for multiline comments. - * - * This routine also supports the C++ extension for single line comments. - * These comments are started with "//" and end at the end of the line. - * - * The function also detects (and manages) "documentation comments". The - * global variable "icomment" is set to 2 for documentation comments. - * - * Global references: icomment (private to "stripcom") - */ -static void stripcom(unsigned char *line) -{ - char c; - #if !defined SC_LIGHT - #define COMMENT_LIMIT 100 - #define COMMENT_MARGIN 40 /* length of the longest word */ - char comment[COMMENT_LIMIT+COMMENT_MARGIN]; - int commentidx=0; - int skipstar=TRUE; - static int prev_singleline=FALSE; - int singleline=prev_singleline; - - prev_singleline=FALSE; /* preset */ - #endif - - while (*line){ - if (icomment!=0) { - if (*line=='*' && *(line+1)=='/') { - #if !defined SC_LIGHT - if (icomment==2) { - assert(commentidx0) - insert_docstring(comment); - } /* if */ - #endif - icomment=0; /* comment has ended */ - *line=' '; /* replace '*' and '/' characters by spaces */ - *(line+1)=' '; - line+=2; - } else { - if (*line=='/' && *(line+1)=='*') - error(216); /* nested comment */ - #if !defined SC_LIGHT - /* collect the comment characters in a string */ - if (icomment==2) { - if (skipstar && ((*line!='\0' && *line<=' ') || *line=='*')) { - /* ignore leading whitespace and '*' characters */ - } else if (commentidxCOMMENT_LIMIT && *line!='\0' && *line<=' ') { - comment[commentidx]='\0'; - insert_docstring(comment); - commentidx=0; - } /* if */ - skipstar=FALSE; - } /* if */ - } /* if */ - #endif - *line=' '; /* replace comments by spaces */ - line+=1; - } /* if */ - } else { - if (*line=='/' && *(line+1)=='*'){ - icomment=1; /* start comment */ - #if !defined SC_LIGHT - /* there must be two "*" behind the slash and then white space */ - if (*(line+2)=='*' && *(line+3)<=' ') { - /* if we are not in a function, we must attach the previous block - * to the global documentation - */ - if (curfunc==NULL && get_docstring(0)!=NULL) - sc_attachdocumentation(NULL); - icomment=2; /* documentation comment */ - } /* if */ - commentidx=0; - skipstar=TRUE; - #endif - *line=' '; /* replace '/' and '*' characters by spaces */ - *(line+1)=' '; - line+=2; - if (icomment==2) - *line++=' '; - } else if (*line=='/' && *(line+1)=='/'){ /* comment to end of line */ - if (strchr((char*)line,'\a')!=NULL) - error(49); /* invalid line continuation */ - #if !defined SC_LIGHT - if (*(line+2)=='/' && *(line+3)<=' ') { - /* documentation comment */ - char *str=(char*)line+3; - char *end; - while (*str<=' ' && *str!='\0') - str++; /* skip leading whitespace */ - if ((end=strrchr(str,'\n'))!=NULL) - *end='\0';/* erase trailing '\n' */ - /* if there is a disjunct block, we may need to attach the previous - * block to the global documentation - */ - if (!singleline && curfunc==NULL && get_docstring(0)!=NULL) - sc_attachdocumentation(NULL); - insert_docstring(str); - prev_singleline=TRUE; - } /* if */ - #endif - *line++='\n'; /* put "newline" at first slash */ - *line='\0'; /* put "zero-terminator" at second slash */ - } else { - if (*line=='\"' || *line=='\''){ /* leave literals unaltered */ - c=*line; /* ending quote, single or double */ - line+=1; - while ((*line!=c || *(line-1)==sc_ctrlchar) && *line!='\0') - line+=1; - line+=1; /* skip final quote */ - } else { - line+=1; - } /* if */ - } /* if */ - } /* if */ - } /* while */ - #if !defined SC_LIGHT - if (icomment==2) { - assert(commentidx0) - insert_docstring(comment); - } /* if */ - #endif -} - -/* btoi - * - * Attempts to interpret a numeric symbol as a boolean value. On success - * it returns the number of characters processed (so the line pointer can be - * adjusted) and the value is stored in "val". Otherwise it returns 0 and - * "val" is garbage. - * - * A boolean value must start with "0b" - */ -static int btoi(cell *val,const unsigned char *curptr) -{ - const unsigned char *ptr; - - *val=0; - ptr=curptr; - if (*ptr=='0' && *(ptr+1)=='b') { - ptr+=2; - while (*ptr=='0' || *ptr=='1' || *ptr=='_') { - if (*ptr!='_') - *val=(*val<<1) | (*ptr-'0'); - ptr++; - } /* while */ - } else { - return 0; - } /* if */ - if (alphanum(*ptr)) /* number must be delimited by non-alphanumeric char */ - return 0; - else - return (int)(ptr-curptr); -} - -/* dtoi - * - * Attempts to interpret a numeric symbol as a decimal value. On success - * it returns the number of characters processed and the value is stored in - * "val". Otherwise it returns 0 and "val" is garbage. - */ -static int dtoi(cell *val,const unsigned char *curptr) -{ - const unsigned char *ptr; - - *val=0; - ptr=curptr; - if (!isdigit(*ptr)) /* should start with digit */ - return 0; - while (isdigit(*ptr) || *ptr=='_') { - if (*ptr!='_') - *val=(*val*10)+(*ptr-'0'); - ptr++; - } /* while */ - if (alphanum(*ptr)) /* number must be delimited by non-alphanumerical */ - return 0; - if (*ptr=='.' && isdigit(*(ptr+1))) - return 0; /* but a fractional part must not be present */ - return (int)(ptr-curptr); -} - -/* htoi - * - * Attempts to interpret a numeric symbol as a hexadecimal value. On - * success it returns the number of characters processed and the value is - * stored in "val". Otherwise it return 0 and "val" is garbage. - */ -static int htoi(cell *val,const unsigned char *curptr) -{ - const unsigned char *ptr; - - *val=0; - ptr=curptr; - if (!isdigit(*ptr)) /* should start with digit */ - return 0; - if (*ptr=='0' && *(ptr+1)=='x') { /* C style hexadecimal notation */ - ptr+=2; - while (ishex(*ptr) || *ptr=='_') { - if (*ptr!='_') { - assert(ishex(*ptr)); - *val= *val<<4; - if (isdigit(*ptr)) - *val+= (*ptr-'0'); - else - *val+= (tolower(*ptr)-'a'+10); - } /* if */ - ptr++; - } /* while */ - } else { - return 0; - } /* if */ - if (alphanum(*ptr)) - return 0; - else - return (int)(ptr-curptr); -} - -/* ftoi - * - * Attempts to interpret a numeric symbol as a rational number, either as - * IEEE 754 single/double precision floating point or as a fixed point integer. - * On success it returns the number of characters processed and the value is - * stored in "val". Otherwise it returns 0 and "val" is unchanged. - * - * Pawn has stricter definition for rational numbers than most: - * o the value must start with a digit; ".5" is not a valid number, you - * should write "0.5" - * o a period must appear in the value, even if an exponent is given; "2e3" - * is not a valid number, you should write "2.0e3" - * o at least one digit must follow the period; "6." is not a valid number, - * you should write "6.0" - */ -static int ftoi(cell *val,const unsigned char *curptr) -{ - const unsigned char *ptr; - double fnum,ffrac,fmult; - unsigned long dnum,dbase; - int i, ignore; - - assert(rational_digits>=0 && rational_digits<9); - for (i=0,dbase=1; i0 && !ignore) { - error(222); /* number of digits exceeds rational number precision */ - ignore=TRUE; - } /* if */ - } /* if */ - ptr++; - } /* while */ - fnum += ffrac*fmult; /* form the number so far */ - if (*ptr=='e') { /* optional fractional part */ - int exp,sign; - ptr++; - if (*ptr=='-') { - sign=-1; - ptr++; - } else { - sign=1; - } /* if */ - if (!isdigit(*ptr)) /* 'e' should be followed by a digit */ - return 0; - exp=0; - while (isdigit(*ptr)) { - exp=(exp*10)+(*ptr-'0'); - ptr++; - } /* while */ -#if defined __GNUC__ - fmult=pow10(exp*sign); -#else - fmult=pow(10.0,exp*sign); -#endif - fnum *= fmult; - dnum *= (unsigned long)(fmult+0.5); - } /* if */ - - /* decide how to store the number */ - if (sc_rationaltag==0) { - error(70); /* rational number support was not enabled */ - *val=0; - } else if (rational_digits==0) { - /* floating point */ - #if PAWN_CELL_SIZE==32 - float value=(float)fnum; - *val=*((cell *)&value); - #if 0 /* SourceMod - not needed */ - /* I assume that the C/C++ compiler stores "float" values in IEEE 754 - * format (as mandated in the ANSI standard). Test this assumption - * anyway. - * Note: problems have been reported with GCC 3.2.x, version 3.3.x works. - */ - { float test1 = 0.0, test2 = 50.0, test3 = -50.0; - uint32_t bit = 1; - /* test 0.0 == all bits 0 */ - assert(*(uint32_t*)&test1==0x00000000L); - /* test sign & magnitude format */ - assert(((*(uint32_t*)&test2) ^ (*(uint32_t*)&test3)) == (bit << (PAWN_CELL_SIZE-1))); - /* test a known value */ - assert(*(uint32_t*)&test2==0x42480000L); - } - #endif - #elif PAWN_CELL_SIZE==64 - *val=*((cell *)&fnum); - #if 0 /* SourceMod - not needed */ - /* I assume that the C/C++ compiler stores "double" values in IEEE 754 - * format (as mandated in the ANSI standard). - */ - { float test1 = 0.0, test2 = 50.0, test3 = -50.0; - uint64_t bit = 1; - /* test 0.0 == all bits 0 */ - assert(*(uint64_t*)&test1==0x00000000L); - /* test sign & magnitude format */ - assert(((*(uint64_t*)&test2) ^ (*(uint64_t*)&test3)) == (bit << (PAWN_CELL_SIZE-1))); - } - #endif - #else - #error Unsupported cell size - #endif - } else { - /* fixed point */ - *val=(cell)dnum; - } /* if */ - - return (int)(ptr-curptr); -} - -/* number - * - * Reads in a number (binary, decimal or hexadecimal). It returns the number - * of characters processed or 0 if the symbol couldn't be interpreted as a - * number (in this case the argument "val" remains unchanged). This routine - * relies on the 'early dropout' implementation of the logical or (||) - * operator. - * - * Note: the routine doesn't check for a sign (+ or -). The - is checked - * for at "hier2()" (in fact, it is viewed as an operator, not as a - * sign) and the + is invalid (as in K&R C, and unlike ANSI C). - */ -static int number(cell *val,const unsigned char *curptr) -{ - int i; - cell value; - - if ((i=btoi(&value,curptr))!=0 /* binary? */ - || (i=htoi(&value,curptr))!=0 /* hexadecimal? */ - || (i=dtoi(&value,curptr))!=0) /* decimal? */ - { - *val=value; - return i; - } else { - return 0; /* else not a number */ - } /* if */ -} - -static void chrcat(char *str,char chr) -{ - str=strchr(str,'\0'); - *str++=chr; - *str='\0'; -} - -static int preproc_expr(cell *val,int *tag) -{ - int result; - int index; - cell code_index; - char *term; - - /* Disable staging; it should be disabled already because - * expressions may not be cut off half-way between conditional - * compilations. Reset the staging index, but keep the code - * index. - */ - if (stgget(&index,&code_index)) { - error(57); /* unfinished expression */ - stgdel(0,code_index); - stgset(FALSE); - } /* if */ - assert((lptr-pline)<(int)strlen((char*)pline)); /* lptr must point inside the string */ - #if !defined NO_DEFINE - /* preprocess the string */ - substallpatterns(pline,sLINEMAX); - assert((lptr-pline)<(int)strlen((char*)pline)); /* lptr must STILL point inside the string */ - #endif - /* append a special symbol to the string, so the expression - * analyzer won't try to read a next line when it encounters - * an end-of-line - */ - assert(strlen((char*)pline)=0); - if (iflevel>=sCOMP_STACK) - error(FATAL_ERROR_ALLOC_OVERFLOW,"Conditional compilation stack"); - iflevel++; - if (SKIPPING) - break; /* break out of switch */ - skiplevel=iflevel; - preproc_expr(&val,NULL); /* get value (or 0 on error) */ - ifstack[iflevel-1]=(char)(val ? PARSEMODE : SKIPMODE); - check_empty(lptr); - break; - case tpELSE: - case tpELSEIF: - ret=CMD_IF; - assert(iflevel>=0); - if (iflevel==0) { - error(26); /* no matching #if */ - errorset(sRESET,0); - } else { - /* check for earlier #else */ - if ((ifstack[iflevel-1] & HANDLED_ELSE)==HANDLED_ELSE) { - if (tok==tpELSEIF) - error(61); /* #elseif directive may not follow an #else */ - else - error(60); /* multiple #else directives between #if ... #endif */ - errorset(sRESET,0); - } else { - assert(iflevel>0); - /* if there has been a "parse mode" on this level, set "skip mode", - * otherwise, clear "skip mode" - */ - if ((ifstack[iflevel-1] & PARSEMODE)==PARSEMODE) { - /* there has been a parse mode already on this level, so skip the rest */ - ifstack[iflevel-1] |= (char)SKIPMODE; - /* if we were already skipping this section, allow expressions with - * undefined symbols; otherwise check the expression to catch errors - */ - if (tok==tpELSEIF) { - if (skiplevel==iflevel) - preproc_expr(&val,NULL); /* get, but ignore the expression */ - else - lptr=(unsigned char*)strchr((char*)lptr,'\0'); - } /* if */ - } else { - /* previous conditions were all FALSE */ - if (tok==tpELSEIF) { - /* if we were already skipping this section, allow expressions with - * undefined symbols; otherwise check the expression to catch errors - */ - if (skiplevel==iflevel) { - preproc_expr(&val,NULL); /* get value (or 0 on error) */ - } else { - lptr=(unsigned char*)strchr((char*)lptr,'\0'); - val=0; - } /* if */ - ifstack[iflevel-1]=(char)(val ? PARSEMODE : SKIPMODE); - } else { - /* a simple #else, clear skip mode */ - ifstack[iflevel-1] &= (char)~SKIPMODE; - } /* if */ - } /* if */ - } /* if */ - } /* if */ - check_empty(lptr); - break; - case tpENDIF: - ret=CMD_IF; - if (iflevel==0){ - error(26); /* no matching "#if" */ - errorset(sRESET,0); - } else { - iflevel--; - if (iflevel0) { - free(inpfname); - inpfname=duplicatestring(pathname); - if (inpfname==NULL) - error(FATAL_ERROR_OOM); - fline=0; - } /* if */ - } /* if */ - check_empty(lptr); - break; - case tpLINE: - if (!SKIPPING) { - if (lex(&val,&str)!=tNUMBER) - error(8); /* invalid/non-constant expression */ - fline=(int)val; - } /* if */ - check_empty(lptr); - break; - case tpASSERT: - if (!SKIPPING && (sc_debug & sCHKBOUNDS)!=0) { - for (str=(char*)lptr; *str<=' ' && *str!='\0'; str++) - /* nothing */; /* save start of expression */ - preproc_expr(&val,NULL); /* get constant expression (or 0 on error) */ - if (!val) - error(170,str); /* assertion failed */ - check_empty(lptr); - } /* if */ - break; - case tpPRAGMA: - if (!SKIPPING) { - if (lex(&val,&str)==tSYMBOL) { - if (strcmp(str,"amxlimit")==0) { - preproc_expr(&pc_amxlimit,NULL); - } else if (strcmp(str,"amxram")==0) { - preproc_expr(&pc_amxram,NULL); - } else if (strcmp(str,"codepage")==0) { - char name[sNAMEMAX+1]; - while (*lptr<=' ' && *lptr!='\0') - lptr++; - if (*lptr=='"') { - lptr=getstring((unsigned char*)name,sizeof name,lptr); - } else { - int i; - for (i=0; i9) { - error(68); /* invalid rational number precision */ - digits=0; - } /* if */ - if (*lptr==')') - lptr++; - } /* if */ - /* add the tag (make it public) and check the values */ - i=pc_addtag(name); - if (sc_rationaltag==0 || (sc_rationaltag==i && rational_digits==(int)digits)) { - sc_rationaltag=i; - rational_digits=(int)digits; - } else { - error(69); /* rational number format already set, can only be set once */ - } /* if */ - } else if (strcmp(str,"semicolon")==0) { - cell val; - preproc_expr(&val,NULL); - sc_needsemicolon=(int)val; - } else if (strcmp(str, "newdecls")==0) { - while (*lptr<=' ' && *lptr!='\0') - lptr++; - if (strncmp((char *)lptr, "required", 8) == 0) - sc_require_newdecls = 1; - else if (strncmp((char *)lptr, "optional", 8) == 0) - sc_require_newdecls = 0; - else - error(146); - lptr=(unsigned char*)strchr((char*)lptr,'\0'); /* skip to end (ignore "extra characters on line") */ - } else if (strcmp(str,"tabsize")==0) { - cell val; - preproc_expr(&val,NULL); - sc_tabsize=(int)val; - } else if (strcmp(str,"align")==0) { - sc_alignnext=TRUE; - } else if (strcmp(str,"unused")==0) { - char name[sNAMEMAX+1]; - int i,comma; - symbol *sym; - do { - /* get the name */ - while (*lptr<=' ' && *lptr!='\0') - lptr++; - for (i=0; iusage |= uREAD; - if (sym->ident==iVARIABLE || sym->ident==iREFERENCE - || sym->ident==iARRAY || sym->ident==iREFARRAY) - sym->usage |= uWRITTEN; - } else { - error(17,name); /* undefined symbol */ - } /* if */ - /* see if a comma follows the name */ - while (*lptr<=' ' && *lptr!='\0') - lptr++; - comma= (*lptr==','); - if (comma) - lptr++; - } while (comma); - } else { - error(207); /* unknown #pragma */ - } /* if */ - } else { - error(207); /* unknown #pragma */ - } /* if */ - check_empty(lptr); - } /* if */ - break; - case tpENDINPUT: - case tpENDSCRPT: - if (!SKIPPING) { - check_empty(lptr); - assert(inpf!=NULL); - if (inpf!=inpf_org) - pc_closesrc(inpf); - inpf=NULL; - } /* if */ - break; -#if !defined NO_DEFINE - case tpDEFINE: { - ret=CMD_DEFINE; - if (!SKIPPING) { - char *pattern,*substitution; - const unsigned char *start,*end; - int count,prefixlen; - stringpair *def; - /* find the pattern to match */ - while (*lptr<=' ' && *lptr!='\0') - lptr++; - start=lptr; /* save starting point of the match pattern */ - count=0; - while (*lptr>' ' && *lptr!='\0') { - litchar(&lptr,0); /* litchar() advances "lptr" and handles escape characters */ - count++; - } /* while */ - end=lptr; - /* check pattern to match */ - if (!alpha(*start)) { - error(74); /* pattern must start with an alphabetic character */ - break; - } /* if */ - /* store matched pattern */ - pattern=(char*)malloc(count+1); - if (pattern==NULL) - error(FATAL_ERROR_OOM); - lptr=start; - count=0; - while (lptr!=end) { - assert(lptr=2 && isdigit(pattern[count-1]) && pattern[count-2]=='%') - pattern[count-2]='\0'; - /* find substitution string */ - while (*lptr<=' ' && *lptr!='\0') - lptr++; - start=lptr; /* save starting point of the match pattern */ - count=0; - end=NULL; - while (*lptr!='\0') { - /* keep position of the start of trailing whitespace */ - if (*lptr<=' ') { - if (end==NULL) - end=lptr; - } else { - end=NULL; - } /* if */ - count++; - lptr++; - } /* while */ - if (end==NULL) - end=lptr; - /* store matched substitution */ - substitution=(char*)malloc(count+1); /* +1 for '\0' */ - if (substitution==NULL) - error(FATAL_ERROR_OOM); - lptr=start; - count=0; - while (lptr!=end) { - assert(lptr0); - if ((def=find_subst(pattern,prefixlen))!=NULL) { - if (strcmp(def->first,pattern)!=0 || strcmp(def->second,substitution)!=0) - error(201,pattern); /* redefinition of macro (non-identical) */ - delete_subst(pattern,prefixlen); - } /* if */ - /* add the pattern/substitution pair to the list */ - assert(strlen(pattern)>0); - insert_subst(pattern,substitution,prefixlen); - free(pattern); - free(substitution); - } /* if */ - break; - } /* case */ - case tpUNDEF: - if (!SKIPPING) { - if (lex(&val,&str)==tSYMBOL) { - ret=delete_subst(str,strlen(str)); - if (!ret) { - /* also undefine normal constants */ - symbol *sym=findconst(str,NULL); - if (sym!=NULL && (sym->usage & (uENUMROOT | uENUMFIELD))==0) { - delete_symbol(&glbtab,sym); - ret=TRUE; - } /* if */ - } /* if */ - if (!ret) - error(17,str); /* undefined symbol */ - } else { - error(20,str); /* invalid symbol name */ - } /* if */ - check_empty(lptr); - } /* if */ - break; -#endif - case tpERROR: - while (*lptr<=' ' && *lptr!='\0') - lptr++; - if (!SKIPPING) - error(171,lptr); /* user error */ - break; - default: - error(31); /* unknown compiler directive */ - ret=SKIPPING ? CMD_CONDFALSE : CMD_NONE; /* process as normal line */ - } /* switch */ - return ret; -} - -#if !defined NO_DEFINE -static int is_startstring(const unsigned char *string) -{ - if (*string=='\"' || *string=='\'') - return TRUE; /* "..." */ - - if (*string=='!') { - string++; - if (*string=='\"' || *string=='\'') - return TRUE; /* !"..." */ - if (*string==sc_ctrlchar) { - string++; - if (*string=='\"' || *string=='\'') - return TRUE; /* !\"..." */ - } /* if */ - } else if (*string==sc_ctrlchar) { - string++; - if (*string=='\"' || *string=='\'') - return TRUE; /* \"..." */ - if (*string=='!') { - string++; - if (*string=='\"' || *string=='\'') - return TRUE; /* \!"..." */ - } /* if */ - } /* if */ - - return FALSE; -} - -static const unsigned char *skipstring(const unsigned char *string) -{ - char endquote; - int flags=0; - - while (*string=='!' || *string==sc_ctrlchar) { - if (*string==sc_ctrlchar) - flags=RAWMODE; - string++; - } /* while */ - - endquote=*string; - assert(endquote=='"' || endquote=='\''); - string++; /* skip open quote */ - while (*string!=endquote && *string!='\0') - litchar(&string,flags); - return string; -} - -static const unsigned char *skippgroup(const unsigned char *string) -{ - int nest=0; - char open=*string; - char close; - - switch (open) { - case '(': - close=')'; - break; - case '{': - close='}'; - break; - case '[': - close=']'; - break; - case '<': - close='>'; - break; - default: - assert(0); - close='\0'; /* only to avoid a compiler warning */ - }/* switch */ - - string++; - while (*string!=close || nest>0) { - if (*string==open) - nest++; - else if (*string==close) - nest--; - else if (is_startstring(string)) - string=skipstring(string); - if (*string=='\0') - break; - string++; - } /* while */ - return string; -} - -static char *strdel(char *str,size_t len) -{ - size_t length=strlen(str); - if (len>length) - len=length; - memmove(str, str+len, length-len+1); /* include EOS byte */ - return str; -} - -static char *strins(char *dest,const char *src,size_t srclen) -{ - size_t destlen=strlen(dest); - assert(srclen<=strlen(src)); - memmove(dest+srclen, dest, destlen+1);/* include EOS byte */ - memcpy(dest, src, srclen); - return dest; -} - -static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char *substitution) -{ - int prefixlen; - const unsigned char *p,*s,*e; - unsigned char *args[10]; - int match,arg,len,argsnum=0; - int stringize; - - memset(args,0,sizeof args); - - /* check the length of the prefix */ - for (prefixlen=0,s=(unsigned char*)pattern; alphanum(*s); prefixlen++,s++) - /* nothing */; - assert(prefixlen>0); - assert(strncmp((char*)line,pattern,prefixlen)==0); - - /* pattern prefix matches; match the rest of the pattern, gather - * the parameters - */ - s=line+prefixlen; - p=(unsigned char*)pattern+prefixlen; - match=TRUE; /* so far, pattern matches */ - while (match && *s!='\0' && *p!='\0') { - if (*p=='%') { - p++; /* skip '%' */ - if (isdigit(*p)) { - arg=*p-'0'; - assert(arg>=0 && arg<=9); - p++; /* skip parameter id */ - assert(*p!='\0'); - /* match the source string up to the character after the digit - * (skipping strings in the process - */ - e=s; - while (*e!=*p && *e!='\0' && *e!='\n') { - if (is_startstring(e)) /* skip strings */ - e=skipstring(e); - else if (strchr("({[",*e)!=NULL) /* skip parenthized groups */ - e=skippgroup(e); - if (*e!='\0') - e++; /* skip non-alphapetic character (or closing quote of - * a string, or the closing paranthese of a group) */ - } /* while */ - /* store the parameter (overrule any earlier) */ - if (args[arg]!=NULL) - free(args[arg]); - else - argsnum++; - len=(int)(e-s); - args[arg]=(unsigned char*)malloc(len+1); - if (args[arg]==NULL) - error(FATAL_ERROR_OOM); - strlcpy((char*)args[arg],(char*)s,len+1); - /* character behind the pattern was matched too */ - if (*e==*p) { - s=e+1; - } else if (*e=='\n' && *p==';' && *(p+1)=='\0' && !sc_needsemicolon) { - s=e; /* allow a trailing ; in the pattern match to end of line */ - } else { - assert(*e=='\0' || *e=='\n'); - match=FALSE; - s=e; - } /* if */ - p++; - } else { - match=FALSE; - } /* if */ - } else if (*p==';' && *(p+1)=='\0' && !sc_needsemicolon) { - /* source may be ';' or end of the line */ - while (*s<=' ' && *s!='\0') - s++; /* skip white space */ - if (*s!=';' && *s!='\0') - match=FALSE; - p++; /* skip the semicolon in the pattern */ - } else { - cell ch; - /* skip whitespace between two non-alphanumeric characters, except - * for two identical symbols - */ - assert((char*)p>pattern); - if (!alphanum(*p) && *(p-1)!=*p) - while (*s<=' ' && *s!='\0') - s++; /* skip white space */ - ch=litchar(&p,0); /* this increments "p" */ - if (*s!=ch) - match=FALSE; - else - s++; /* this character matches */ - } /* if */ - } /* while */ - - if (match && *p=='\0') { - /* if the last character to match is an alphanumeric character, the - * current character in the source may not be alphanumeric - */ - assert(p>(unsigned char*)pattern); - if (alphanum(*(p-1)) && alphanum(*s)) - match=FALSE; - } /* if */ - - if (match) { - /* calculate the length of the substituted string */ - for (e=(unsigned char*)substitution,len=0; *e!='\0'; e++) { - if(*e=='#' && *(e+1)=='%' && isdigit(*(e+2)) && argsnum) { - stringize=1; - e++; /* skip '#' */ - } else { - stringize=0; - } /* if */ - if (*e=='%' && isdigit(*(e+1)) && argsnum) { - arg=*(e+1)-'0'; - assert(arg>=0 && arg<=9); - assert(stringize==0 || stringize==1); - if (args[arg]!=NULL) { - len+=strlen((char*)args[arg])+2*stringize; - e++; - } else { - len++; - } - } else { - len++; - } /* if */ - } /* for */ - /* check length of the string after substitution */ - if (strlen((char*)line) + len - (int)(s-line) > buffersize) { - error(75); /* line too long */ - } else { - /* substitute pattern */ - strdel((char*)line,(int)(s-line)); - for (e=(unsigned char*)substitution,s=line; *e!='\0'; e++) { - if (*e=='#' && *(e+1)=='%' && isdigit(*(e+2))) { - stringize=1; - e++; /* skip '#' */ - } else { - stringize=0; - } /* if */ - if (*e=='%' && isdigit(*(e+1))) { - arg=*(e+1)-'0'; - assert(arg>=0 && arg<=9); - if (args[arg]!=NULL) { - if (stringize) - strins((char*)s++,"\"",1); - strins((char*)s,(char*)args[arg],strlen((char*)args[arg])); - s+=strlen((char*)args[arg]); - if (stringize) - strins((char*)s++,"\"",1); - } else { - error(236); /* parameter does not exist, incorrect #define pattern */ - strins((char*)s,(char*)e,2); - s+=2; - } /* if */ - e++; /* skip %, digit is skipped later */ - } else if (*e == '"') { - p=e; - if (is_startstring(e)) { - e=skipstring(e); - strins((char*)s,(char *)p,(e-p+1)); - s+=(e-p+1); - } else { - strins((char*)s,(char*)e,1); - s++; - } - } else { - strins((char*)s,(char*)e,1); - s++; - } /* if */ - } /* for */ - } /* if */ - } /* if */ - - for (arg=0; arg<10; arg++) - if (args[arg]!=NULL) - free(args[arg]); - - return match; -} - -static void substallpatterns(unsigned char *line,int buffersize) -{ - unsigned char *start, *end; - int prefixlen; - stringpair *subst; - - start=line; - while (*start!='\0') { - /* find the start of a prefix (skip all non-alphabetic characters), - * also skip strings - */ - while (!alpha(*start) && *start!='\0') { - /* skip strings */ - if (is_startstring(start)) { - start=(unsigned char *)skipstring(start); - if (*start=='\0') - break; /* abort loop on error */ - } /* if */ - start++; /* skip non-alphapetic character (or closing quote of a string) */ - } /* while */ - if (*start=='\0') - break; /* abort loop on error */ - /* if matching the operator "defined", skip it plus the symbol behind it */ - if (strncmp((char*)start,"defined",7)==0 && !isalpha((char)*(start+7))) { - start+=7; /* skip "defined" */ - /* skip white space & parantheses */ - while ((*start<=' ' && *start!='\0') || *start=='(') - start++; - /* skip the symbol behind it */ - while (alphanum(*start)) - start++; - /* drop back into the main loop */ - continue; - } /* if */ - /* get the prefix (length), look for a matching definition */ - prefixlen=0; - end=start; - while (alphanum(*end)) { - prefixlen++; - end++; - } /* while */ - assert(prefixlen>0); - subst=find_subst((char*)start,prefixlen); - if (subst!=NULL) { - /* properly match the pattern and substitute */ - if (!substpattern(start,buffersize-(int)(start-line),subst->first,subst->second)) - start=end; /* match failed, skip this prefix */ - /* match succeeded: do not update "start", because the substitution text - * may be matched by other macros - */ - } else { - start=end; /* no macro with this prefix, skip this prefix */ - } /* if */ - } /* while */ -} -#endif - -/* scanellipsis - * Look for ... in the string and (if not there) in the remainder of the file, - * but restore (or keep intact): - * - the current position in the file - * - the comment parsing state - * - the line buffer used by the lexical analyser - * - the active line number and the active file - * - * The function returns 1 if an ellipsis was found and 0 if not - */ -static int scanellipsis(const unsigned char *lptr) -{ - static void *inpfmark=NULL; - unsigned char *localbuf; - short localcomment,found; - - /* first look for the ellipsis in the remainder of the string */ - while (*lptr<=' ' && *lptr!='\0') - lptr++; - if (lptr[0]=='.' && lptr[1]=='.' && lptr[2]=='.') - return 1; - if (*lptr!='\0') - return 0; /* stumbled on something that is not an ellipsis and not white-space */ - - /* the ellipsis was not on the active line, read more lines from the current - * file (but save its position first) - */ - if (inpf==NULL || pc_eofsrc(inpf)) - return 0; /* quick exit: cannot read after EOF */ - if ((localbuf=(unsigned char*)malloc((sLINEMAX+1)*sizeof(unsigned char)))==NULL) - return 0; - inpfmark=pc_getpossrc(inpf,inpfmark); - localcomment=icomment; - - found=0; - /* read from the file, skip preprocessing, but strip off comments */ - while (!found && pc_readsrc(inpf,localbuf,sLINEMAX)!=NULL) { - stripcom(localbuf); - lptr=localbuf; - /* skip white space */ - while (*lptr<=' ' && *lptr!='\0') - lptr++; - if (lptr[0]=='.' && lptr[1]=='.' && lptr[2]=='.') - found=1; - else if (*lptr!='\0') - break; /* stumbled on something that is not an ellipsis and not white-space */ - } /* while */ - - /* clean up & reset */ - free(localbuf); - pc_resetsrc(inpf,inpfmark); - icomment=localcomment; - return found; -} - -/* preprocess - * - * Reads a line by readline() into "pline" and performs basic preprocessing: - * deleting comments, skipping lines with false "#if.." code and recognizing - * other compiler directives. There is an indirect recursion: lex() calls - * preprocess() if a new line must be read, preprocess() calls command(), - * which at his turn calls lex() to identify the token. - * - * Global references: lptr (altered) - * pline (altered) - * freading (referred to only) - */ -void preprocess(void) -{ - int iscommand; - - if (!freading) - return; - do { - readline(pline); - stripcom(pline); /* ??? no need for this when reading back from list file (in the second pass) */ - lptr=pline; /* set "line pointer" to start of the parsing buffer */ - iscommand=command(); - if (iscommand!=CMD_NONE) - errorset(sRESET,0); /* reset error flag ("panic mode") on empty line or directive */ - #if !defined NO_DEFINE - if (iscommand==CMD_NONE) { - assert(lptr!=term_expr); - substallpatterns(pline,sLINEMAX); - lptr=pline; /* reset "line pointer" to start of the parsing buffer */ - } /* if */ - #endif - if (sc_status==statFIRST && sc_listing && freading - && (iscommand==CMD_NONE || iscommand==CMD_EMPTYLINE || iscommand==CMD_DIRECTIVE)) - { - listline++; - if (fline!=listline) { - listline=fline; - setlinedirect(fline); - } /* if */ - if (iscommand==CMD_EMPTYLINE) - pc_writeasm(outf,"\n"); - else - pc_writeasm(outf,(char*)pline); - } /* if */ - } while (iscommand!=CMD_NONE && iscommand!=CMD_TERM && freading); /* enddo */ -} - -static const unsigned char *unpackedstring(const unsigned char *lptr,int flags) -{ - while (*lptr!='\"' && *lptr!='\0') { - if (*lptr=='\a') { /* ignore '\a' (which was inserted at a line concatenation) */ - lptr++; - continue; - } /* if */ - litadd(litchar(&lptr,flags | UTF8MODE)); /* litchar() alters "lptr" */ - } /* while */ - litadd(0); /* terminate string */ - return lptr; -} - -static const unsigned char *packedstring(const unsigned char *lptr,int flags) -{ - int i; - ucell val,c; - - i=0; /* start at least significant byte */ - val=0; - glbstringread=1; - while (*lptr!='\"' && *lptr!='\0') { - if (*lptr=='\a') { /* ignore '\a' (which was inserted at a line concatenation) */ - lptr++; - continue; - } /* if */ - c=litchar(&lptr,flags); /* litchar() alters "lptr" */ - if (c>=(ucell)(1 << sCHARBITS)) - error(43); /* character constant exceeds range */ - val |= (c << 8*i); - glbstringread++; - if (i==sizeof(ucell)-(sCHARBITS/8)) { - litadd(val); - val=0; - i=0; - } else { - i=i+1; - } - } /* if */ - /* save last code; make sure there is at least one terminating zero character */ - if (i!=0) - litadd(val); /* at least one zero character in "val" */ - else - litadd(0); /* add full cell of zeros */ - return lptr; -} - -/* lex(lexvalue,lexsym) Lexical Analysis - * - * lex() first deletes leading white space, then checks for multi-character - * operators, keywords (including most compiler directives), numbers, - * labels, symbols and literals (literal characters are converted to a number - * and are returned as such). If every check fails, the line must contain - * a single-character operator. So, lex() returns this character. In the other - * case (something did match), lex() returns the number of the token. All - * these tokens have been assigned numbers above 255. - * - * Some tokens have "attributes": - * tNUMBER the value of the number is return in "lexvalue". - * tRATIONAL the value is in IEEE 754 encoding or in fixed point - * encoding in "lexvalue". - * tSYMBOL the first sNAMEMAX characters of the symbol are - * stored in a buffer, a pointer to this buffer is - * returned in "lexsym". - * tLABEL the first sNAMEMAX characters of the label are - * stored in a buffer, a pointer to this buffer is - * returned in "lexsym". - * tSTRING the string is stored in the literal pool, the index - * in the literal pool to this string is stored in - * "lexvalue". - * - * lex() stores all information (the token found and possibly its attribute) - * in global variables. This allows a token to be examined twice. If "_pushed" - * is true, this information is returned. - * - * Global references: lptr (altered) - * fline (referred to only) - * litidx (referred to only) - * _pushed - */ - -static int _lexnewline; - -// lex() is called recursively, which messes up the lookahead buffer. To get -// around this we use two separate token buffers. -token_buffer_t sNormalBuffer; -token_buffer_t sPreprocessBuffer; -token_buffer_t *sTokenBuffer; - -static full_token_t *current_token() -{ - return &sTokenBuffer->tokens[sTokenBuffer->cursor]; -} - -static full_token_t *next_token() -{ - assert(sTokenBuffer->depth > 0); - int cursor = sTokenBuffer->cursor + 1; - if (cursor == MAX_TOKEN_DEPTH) - cursor = 0; - return &sTokenBuffer->tokens[cursor]; -} - -void lexinit(void) -{ - stkidx=0; /* index for pushstk() and popstk() */ - iflevel=0; /* preprocessor: nesting of "#if" is currently 0 */ - skiplevel=0; /* preprocessor: not currently skipping */ - icomment=0; /* currently not in a multiline comment */ - _lexnewline=FALSE; - memset(&sNormalBuffer, 0, sizeof(sNormalBuffer)); - memset(&sPreprocessBuffer, 0, sizeof(sPreprocessBuffer)); - sTokenBuffer = &sNormalBuffer; -} - -const char *sc_tokens[] = { - "*=", "/=", "%=", "+=", "-=", "<<=", ">>>=", ">>=", "&=", "^=", "|=", - "||", "&&", "==", "!=", "<=", ">=", "<<", ">>>", ">>", "++", "--", - "...", "..", "::", - "acquire", - "as", - "assert", - "*begin", - "break", - "builtin", - "catch", - "case", - "cast_to", - "cellsof", - "char", - "const", - "continue", - "decl", - "default", - "defined", - "delete", - "do", - "double", - "else", - "*end", - "enum", - "exit", - "explicit", - "finally", - "for", - "foreach", - "forward", - "funcenum", - "functag", - "function", - "goto", - "if", - "implicit", - "import", - "in", - "int", - "int8", - "int16", - "int32", - "int64", - "interface", - "intn", - "let", - "methodmap", - "namespace", - "native", - "new", - "null", - "__nullable__", - "object", - "operator", - "package", - "private", - "protected", - "public", - "readonly", - "return", - "sealed", - "sizeof", - "sleep", - "static", - "stock", - "struct", - "switch", - "tagof", - "*then", - "this", - "throw", - "try", - "typedef", - "typeof", - "typeset", - "uint8", - "uint16", - "uint32", - "uint64", - "uintn", - "union", - "using", - "var", - "variant", - "view_as", - "virtual", - "void", - "volatile", - "while", - "with", - "#assert", "#define", "#else", "#elseif", "#endif", "#endinput", - "#endscript", "#error", "#file", "#if", "#include", "#line", "#pragma", - "#tryinclude", "#undef", - ";", ";", "-integer value-", "-rational value-", "-identifier-", - "-label-", "-string-", "-string-" -}; - -static inline bool -IsUnimplementedKeyword(int token) -{ - switch (token) { - case tACQUIRE: - case tAS: - case tCATCH: - case tCAST_TO: - case tDOUBLE: - case tEXPLICIT: - case tFINALLY: - case tFOREACH: - case tIMPLICIT: - case tIMPORT: - case tIN: - case tINT8: - case tINT16: - case tINT32: - case tINT64: - case tINTERFACE: - case tINTN: - case tLET: - case tNAMESPACE: - case tPACKAGE: - case tPRIVATE: - case tPROTECTED: - case tREADONLY: - case tSEALED: - case tTHROW: - case tTRY: - case tTYPEOF: - case tUINT8: - case tUINT16: - case tUINT32: - case tUINT64: - case tUINTN: - case tUNION: - case tUSING: - case tVAR: - case tVARIANT: - case tVIRTUAL: - case tVOLATILE: - case tWITH: - return true; - default: - return false; - } -} - -static full_token_t *advance_token_ptr() -{ - assert(sTokenBuffer->depth == 0); - sTokenBuffer->num_tokens++; - sTokenBuffer->cursor++; - if (sTokenBuffer->cursor == MAX_TOKEN_DEPTH) - sTokenBuffer->cursor = 0; - - return current_token(); -} - -static void preprocess_in_lex() -{ - sTokenBuffer = &sPreprocessBuffer; - preprocess(); - sTokenBuffer = &sNormalBuffer; -} - -// Pops a token off the token buffer, making it the current token. -static void lexpop() -{ - assert(sTokenBuffer->depth > 0); - - sTokenBuffer->depth--; - sTokenBuffer->cursor++; - if (sTokenBuffer->cursor == MAX_TOKEN_DEPTH) - sTokenBuffer->cursor = 0; -} - -int lex(cell *lexvalue,char **lexsym) -{ - int i,toolong,newline; - const unsigned char *starttoken; - - if (sTokenBuffer->depth > 0) { - lexpop(); - *lexvalue = current_token()->value; - *lexsym = current_token()->str; - return current_token()->id; - } - - full_token_t *tok = advance_token_ptr(); - tok->id = 0; - tok->value = 0; - tok->str[0] = '\0'; - tok->len = 0; - - *lexvalue = tok->value; - *lexsym = tok->str; - - _lexnewline=FALSE; - if (!freading) - return 0; - - newline= (lptr==pline); /* does lptr point to start of line buffer */ - while (*lptr<=' ') { /* delete leading white space */ - if (*lptr=='\0') { - preprocess_in_lex(); - if (!freading) - return 0; - if (lptr==term_expr) /* special sequence to terminate a pending expression */ - return (tok->id = tENDEXPR); - _lexnewline=TRUE; /* set this after preprocess(), because - * preprocess() calls lex() recursively */ - newline=TRUE; - } else { - lptr+=1; - } /* if */ - } /* while */ - if (newline) { - stmtindent=0; - for (i=0; i<(int)(lptr-pline); i++) - if (pline[i]=='\t' && sc_tabsize>0) - stmtindent += (int)(sc_tabsize - (stmtindent+sc_tabsize) % sc_tabsize); - else - stmtindent++; - } /* if */ - - tok->start.line = fline; - tok->start.col = (int)(lptr - pline); - - i=tFIRST; - const char **tokptr=sc_tokens; - while (i<=tMIDDLE) { /* match multi-character operators */ - if (*lptr==**tokptr && match(*tokptr,FALSE)) { - tok->id = i; - if (pc_docexpr) /* optionally concatenate to documentation string */ - insert_autolist(*tokptr); - tok->end.line = fline; - tok->end.col = (int)(lptr - pline); - return tok->id; - } /* if */ - i+=1; - tokptr+=1; - } /* while */ - while (i<=tLAST) { /* match reserved words and compiler directives */ - if (*lptr==**tokptr && match(*tokptr,TRUE)) { - if (IsUnimplementedKeyword(i)) { - // Try to gracefully error. - error(173, sc_tokens[i - tFIRST]); - tok->id = tSYMBOL; - strcpy(tok->str, sc_tokens[i - tFIRST]); - tok->len = strlen(tok->str); - } else if (*lptr == ':' && - (i == tINT || - i == tVOID)) - { - // Special case 'int:' to its old behavior: an implicit view_as<> cast - // with Pawn's awful lowercase coercion semantics. - const char *token = sc_tokens[i - tFIRST]; - switch (i) { - case tINT: - error(238, token, token); - break; - case tVOID: - error(239, token, token); - break; - } - lptr++; - tok->id = tLABEL; - strcpy(tok->str, token); - tok->len = strlen(tok->str); - } else { - tok->id = i; - errorset(sRESET,0); /* reset error flag (clear the "panic mode")*/ - if (pc_docexpr) /* optionally concatenate to documentation string */ - insert_autolist(*tokptr); - } - tok->end.line = fline; - tok->end.col = (int)(lptr - pline); - return tok->id; - } /* if */ - i+=1; - tokptr+=1; - } /* while */ - - starttoken=lptr; /* save start pointer (for concatenating to documentation string) */ - if ((i=number(&tok->value, lptr))!=0) { /* number */ - tok->id = tNUMBER; - *lexvalue = tok->value; - lptr+=i; - } else if ((i=ftoi(&tok->value, lptr))!=0) { - tok->id = tRATIONAL; - *lexvalue = tok->value; - lptr+=i; - } else if (alpha(*lptr)) { /* symbol or label */ - /* Note: only sNAMEMAX characters are significant. The compiler - * generates a warning if a symbol exceeds this length. - */ - tok->id = tSYMBOL; - i=0; - toolong=0; - while (alphanum(*lptr)){ - tok->str[i]=*lptr; - lptr+=1; - if (istr[i]='\0'; - tok->len = i; - if (toolong) { - /* symbol too long, truncated to sNAMEMAX chars */ - error(200, tok->str, sNAMEMAX); - } - if (tok->str[0]==PUBLIC_CHAR && tok->str[1]=='\0') { - tok->id = PUBLIC_CHAR; /* '@' all alone is not a symbol, it is an operator */ - } else if (tok->str[0]=='_' && tok->str[1]=='\0') { - tok->id = '_'; /* '_' by itself is not a symbol, it is a placeholder */ - } /* if */ - if (*lptr==':' && *(lptr+1)!=':' && tok->id != PUBLIC_CHAR) { - if (sc_allowtags) { - tok->id = tLABEL; /* it wasn't a normal symbol, it was a label/tagname */ - lptr+=1; /* skip colon */ - } else if (find_constval(&tagname_tab,tok->str,0)!=NULL) { - /* this looks like a tag override (because a tag with this name - * exists), but tags are not allowed right now, so it is probably an - * error - */ - error(220); - } /* if */ - } /* if */ - } else if (*lptr=='\"' /* unpacked string literal */ -#if 0 - || (*lptr==sc_ctrlchar && *(lptr+1)=='\"') /* unpacked raw string */ - || (*lptr=='!' && *(lptr+1)=='\"') /* packed string */ - || (*lptr=='!' && *(lptr+1)==sc_ctrlchar && *(lptr+2)=='\"') /* packed raw string */ - || (*lptr==sc_ctrlchar && *(lptr+1)=='!' && *(lptr+2)=='\"') /* packed raw string */ -#endif - ) - { - if (sLiteralQueueDisabled) { - tok->id = tPENDING_STRING; - tok->end = tok->start; - return tok->id; - } - int stringflags,segmentflags; - char *cat; - tok->id = tSTRING; - *lexvalue = tok->value = litidx; - tok->str[0]='\0'; - stringflags=-1; /* to mark the first segment */ - for ( ;; ) { - if(*lptr=='!') - segmentflags= (*(lptr+1)==sc_ctrlchar) ? RAWMODE | ISPACKED : ISPACKED; - else if (*lptr==sc_ctrlchar) - segmentflags= (*(lptr+1)=='!') ? RAWMODE | ISPACKED : RAWMODE; - else - segmentflags=0; - if ((segmentflags & ISPACKED)!=0) - lptr+=1; /* skip '!' character */ - if ((segmentflags & RAWMODE)!=0) - lptr+=1; /* skip "escape" character too */ - assert(*lptr=='\"'); - lptr+=1; - if (stringflags==-1) - stringflags=segmentflags; - else if (stringflags!=segmentflags) - error(238); /* mixing packed/unpacked/raw strings in concatenation */ - cat=strchr(tok->str,'\0'); - assert(cat!=NULL); - while (*lptr!='\"' && *lptr!='\0' && (cat-tok->str)len = (size_t)(cat - tok->str); - if (*lptr=='\"') - lptr+=1; /* skip final quote */ - else - error(37); /* invalid (non-terminated) string */ - /* see whether an ellipsis is following the string */ - if (!scanellipsis(lptr)) - break; /* no concatenation of string literals */ - /* there is an ellipses, go on parsing (this time with full preprocessing) */ - while (*lptr<=' ') { - if (*lptr=='\0') { - preprocess_in_lex(); - assert(freading && lptr!=term_expr); - } else { - lptr++; - } /* if */ - } /* while */ - assert(freading && lptr[0]=='.' && lptr[1]=='.' && lptr[2]=='.'); - lptr+=3; - while (*lptr<=' ') { - if (*lptr=='\0') { - preprocess_in_lex(); - assert(freading && lptr!=term_expr); - } else { - lptr++; - } /* if */ - } /* while */ - if (!freading || !(*lptr=='\"' -#if 0 - || *lptr==sc_ctrlchar && *(lptr+1)=='\"' - || *lptr=='!' && *(lptr+1)=='\"' - || *lptr=='!' && *(lptr+1)==sc_ctrlchar && *(lptr+2)=='\"' - || *lptr==sc_ctrlchar && *(lptr+1)=='!' && *(lptr+2)=='\"' -#endif - )) - { - error(37); /* invalid string concatenation */ - break; - } /* if */ - } /* for */ - if (sc_packstr) - stringflags ^= ISPACKED; /* invert packed/unpacked parameters */ - if ((stringflags & ISPACKED)!=0) - packedstring((unsigned char *)tok->str,stringflags); - else - unpackedstring((unsigned char *)tok->str,stringflags); - } else if (*lptr=='\'') { /* character literal */ - lptr+=1; /* skip quote */ - tok->id = tNUMBER; - *lexvalue = tok->value = litchar(&lptr,UTF8MODE); - if (*lptr=='\'') - lptr+=1; /* skip final quote */ - else - error(27); /* invalid character constant (must be one character) */ - } else if (*lptr==';') { /* semicolumn resets "error" flag */ - tok->id = ';'; - lptr+=1; - errorset(sRESET,0); /* reset error flag (clear the "panic mode")*/ - } else { - tok->id = *lptr; /* if every match fails, return the character */ - lptr+=1; /* increase the "lptr" pointer */ - } /* if */ - - if (pc_docexpr) { /* optionally concatenate to documentation string */ - char *docstr=(char*)malloc(((int)(lptr-starttoken)+1)*sizeof(char)); - if (docstr!=NULL) { - strlcpy(docstr,(char*)starttoken,(int)(lptr-starttoken)+1); - insert_autolist(docstr); - free(docstr); - } /* if */ - } /* if */ - tok->end.line = fline; - tok->end.col = (int)(lptr - pline); - return tok->id; -} - -/* lexpush - * - * Pushes a token back, so the next call to lex() will return the token - * last examined, instead of a new token. - * - * Only one token can be pushed back. - * - * In fact, lex() already stores the information it finds into global - * variables, so all that is to be done is set a flag that informs lex() - * to read and return the information from these variables, rather than - * to read in a new token from the input file. - */ -void lexpush(void) -{ - if (current_token()->id == tPENDING_STRING) { - // Don't push back fake tokens. - return; - } - - assert(sTokenBuffer->depth < MAX_TOKEN_DEPTH); - sTokenBuffer->depth++; - if (sTokenBuffer->cursor == 0) - sTokenBuffer->cursor = MAX_TOKEN_DEPTH - 1; - else - sTokenBuffer->cursor--; - assert(sTokenBuffer->depth <= sTokenBuffer->num_tokens); -} - -/* lexclr - * - * Sets the variable "_pushed" to 0 to make sure lex() will read in a new - * symbol (a not continue with some old one). This is required upon return - * from Assembler mode, and in a few cases after detecting an syntax error. - */ -void lexclr(int clreol) -{ - sTokenBuffer->depth = 0; - if (clreol) { - lptr=(unsigned char*)strchr((char*)pline,'\0'); - assert(lptr!=NULL); - } /* if */ -} - -// Return true if the symbol is ahead, false otherwise. -int lexpeek(int id) -{ - if (matchtoken(id)) { - lexpush(); - return TRUE; - } - return FALSE; -} - -/* matchtoken - * - * This routine is useful if only a simple check is needed. If the token - * differs from the one expected, it is pushed back. - * This function returns 1 for "token found" and 2 for "implied statement - * termination token" found --the statement termination is an end of line in - * an expression where there is no pending operation. Such an implied token - * (i.e. not present in the source code) should not be pushed back, which is - * why it is sometimes important to distinguish the two. - */ -int matchtoken(int token) -{ - cell val; - char *str; - int tok; - - tok = lex(&val, &str); - - if (token == tok) - return 1; - if (token==tTERM && (tok==';' || tok==tENDEXPR)) - return 1; - - if (!sc_needsemicolon && token==tTERM && (_lexnewline || !freading)) { - /* Push "tok" back, because it is the token following the implicit statement - * termination (newline) token. - */ - lexpush(); - return 2; - } - - lexpush(); - return 0; -} - -/* tokeninfo - * - * Returns additional information of a token after using "matchtoken()" - * or needtoken(). It does no harm using this routine after a call to - * "lex()", but lex() already returns the same information. - * - * The token itself is the return value. Normally, this one is already known. - */ -int tokeninfo(cell *val,char **str) -{ - *val = current_token()->value; - *str = current_token()->str; - return current_token()->id; -} - -/* needtoken - * - * This routine checks for a required token and gives an error message if - * it isn't there (and returns 0/FALSE in that case). Like function matchtoken(), - * this function returns 1 for "token found" and 2 for "statement termination - * token" found; see function matchtoken() for details. - */ -int needtoken(int token) -{ - char s1[20],s2[20]; - int t; - - if ((t=matchtoken(token))!=0) { - return t; - } else { - /* token already pushed back */ - assert(sTokenBuffer->depth > 0); - if (token<256) - sprintf(s1,"%c",(char)token); /* single character token */ - else - strcpy(s1,sc_tokens[token-tFIRST]); /* multi-character symbol */ - if (!freading) - strcpy(s2,"-end of file-"); - else if (next_token()->id < 256) - sprintf(s2,"%c",(char)next_token()->id); - else - strcpy(s2, sc_tokens[next_token()->id - tFIRST]); - error(1,s1,s2); /* expected ..., but found ... */ - return FALSE; - } /* if */ -} - -// If the next token is on the current line, return that token. Otherwise, -// return tNEWLINE. -int peek_same_line() -{ - // We should not call this without having parsed at least one token. - assert(sTokenBuffer->num_tokens > 0); - - // If there's tokens pushed back, then |fline| is the line of the furthest - // token parsed. If fline == current token's line, we are guaranteed any - // buffered token is still on the same line. - if (sTokenBuffer->depth > 0 && current_token()->end.line == fline) - return next_token()->id; - - // Make sure the next token is lexed by lexing, and then buffering it. - full_token_t *next; - { - token_t tmp; - lextok(&tmp); - next = current_token(); - lexpush(); - } - - // If the next token starts on the line the last token ends, then the next - // token is considered on the same line. - if (next->start.line == current_token()->end.line) - return next->id; - - return tEOL; -} - -int require_newline(int allow_semi) -{ - if (allow_semi) { - // Semicolon must be on the same line. - if (peek_same_line() == ';') - lexpop(); - } - - int tokid = peek_same_line(); - if (tokid == tEOL || tokid == 0) - return TRUE; - - char s[20]; - if (tokid < 256) - sprintf(s, "%c", (char)tokid); - else - strcpy(s, sc_tokens[tokid - tFIRST]); - error(155, s); - return FALSE; -} - -/* match - * - * Compares a series of characters from the input file with the characters - * in "st" (that contains a token). If the token on the input file matches - * "st", the input file pointer "lptr" is adjusted to point to the next - * token, otherwise "lptr" remains unaltered. - * - * If the parameter "end: is true, match() requires that the first character - * behind the recognized token is non-alphanumeric. - * - * Global references: lptr (altered) - */ -static int match(const char *st,int end) -{ - int k; - const unsigned char *ptr; - - k=0; - ptr=lptr; - while (st[k]) { - if ((unsigned char)st[k]!=*ptr) - return 0; - k+=1; - ptr+=1; - } /* while */ - if (end) { /* symbol must terminate with non-alphanumeric char */ - if (alphanum(*ptr)) - return 0; - } /* if */ - lptr=ptr; /* match found, skip symbol */ - return 1; -} - -static void chk_grow_litq(void) -{ - if (litidx>=litmax) { - cell *p; - - litmax+=sDEF_LITMAX; - p=(cell *)realloc(litq,litmax*sizeof(cell)); - if (p==NULL) - error(FATAL_ERROR_ALLOC_OVERFLOW,"literal table"); - litq=p; - } /* if */ -} - -/* litadd - * - * Adds a value at the end of the literal queue. The literal queue is used - * for literal strings used in functions and for initializing array variables. - * - * Global references: litidx (altered) - * litq (altered) - */ -void litadd(cell value) -{ - assert(!sLiteralQueueDisabled); - chk_grow_litq(); - assert(litidx=0 && pos<=litidx); - memmove(litq+(pos+1),litq+pos,(litidx-pos)*sizeof(cell)); - litidx++; - litq[pos]=value; -} - -/* litchar - * - * Return current literal character and increase the pointer to point - * just behind this literal character. - * - * Note: standard "escape sequences" are suported, but the backslash may be - * replaced by another character; the syntax '\ddd' is supported, - * but ddd must be decimal! - */ -static cell litchar(const unsigned char **lptr,int flags) -{ - cell c=0; - const unsigned char *cptr; - - cptr=*lptr; - 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 - c=cp_translate(cptr,&cptr); - #else - c=*cptr; - cptr+=1; - #endif - #if !defined NO_UTF8 - } /* if */ - #endif - } else { - cptr+=1; - if (*cptr==sc_ctrlchar) { - c=*cptr; /* \\ == \ (the escape character itself) */ - cptr+=1; - } else { - switch (*cptr) { - case 'a': /* \a == audible alarm */ - c=7; - cptr+=1; - break; - case 'b': /* \b == backspace */ - c=8; - cptr+=1; - break; - case 'e': /* \e == escape */ - c=27; - cptr+=1; - break; - case 'f': /* \f == form feed */ - c=12; - cptr+=1; - break; - case 'n': /* \n == NewLine character */ - c=10; - cptr+=1; - break; - case 'r': /* \r == carriage return */ - c=13; - cptr+=1; - break; - case 't': /* \t == horizontal TAB */ - c=9; - cptr+=1; - break; - case 'v': /* \v == vertical TAB */ - c=11; - cptr+=1; - break; - case 'x': - { - int digits = 0; - cptr+=1; - c=0; - while (ishex(*cptr) && digits < 2) { - if (isdigit(*cptr)) - c=(c<<4)+(*cptr-'0'); - else - c=(c<<4)+(tolower(*cptr)-'a'+10); - cptr++; - digits++; - } /* while */ - if (*cptr==';') - cptr++; /* swallow a trailing ';' */ - break; - } - case '\'': /* \' == ' (single quote) */ - case '"': /* \" == " (single quote) */ - case '%': /* \% == % (percent) */ - c=*cptr; - cptr+=1; - break; - default: - if (isdigit(*cptr)) { /* \ddd */ - c=0; - while (*cptr>='0' && *cptr<='9') /* decimal! */ - c=c*10 + *cptr++ - '0'; - if (*cptr==';') - cptr++; /* swallow a trailing ';' */ - } else { - error(27); /* invalid character constant */ - } /* if */ - } /* switch */ - } /* if */ - } /* if */ - *lptr=cptr; - assert(c>=0); - return c; -} - -/* alpha - * - * Test if character "c" is alphabetic ("a".."z"), an underscore ("_") - * or an "at" sign ("@"). The "@" is an extension to standard C. - */ -static int alpha(char c) -{ - return (isalpha(c) || c=='_' || c==PUBLIC_CHAR); -} - -/* alphanum - * - * Test if character "c" is alphanumeric ("a".."z", "0".."9", "_" or "@") - */ -int alphanum(char c) -{ - return (alpha(c) || isdigit(c)); -} - -/* ishex - * - * Test if character "c" is a hexadecimal digit ("0".."9" or "a".."f"). - */ -int ishex(char c) -{ - return (c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F'); -} - -/* The local variable table must be searched backwards, so that the deepest - * nesting of local variables is searched first. The simplest way to do - * this is to insert all new items at the head of the list. - * In the global list, the symbols are kept in sorted order, so that the - * public functions are written in sorted order. - */ -static symbol *add_symbol(symbol *root,symbol *entry,int sort) -{ - symbol *newsym; - int global = root==&glbtab; - - if (sort) - while (root->next!=NULL && strcmp(entry->name,root->next->name)>0) - root=root->next; - - if ((newsym=(symbol *)malloc(sizeof(symbol)))==NULL) { - error(FATAL_ERROR_OOM); - return NULL; - } /* if */ - memcpy(newsym,entry,sizeof(symbol)); - newsym->next=root->next; - root->next=newsym; - if (global) - AddToHashTable(sp_Globals, newsym); - return newsym; -} - -static void free_symbol(symbol *sym) -{ - arginfo *arg; - - /* free all sub-symbol allocated memory blocks, depending on the - * kind of the symbol - */ - assert(sym!=NULL); - if (sym->ident==iFUNCTN) { - /* run through the argument list; "default array" arguments - * must be freed explicitly; the tag list must also be freed */ - assert(sym->dim.arglist!=NULL); - for (arg=sym->dim.arglist; arg->ident!=0; arg++) { - if (arg->ident==iREFARRAY && arg->hasdefault) - free(arg->defvalue.array.data); - else if (arg->ident==iVARIABLE - && ((arg->hasdefault & uSIZEOF)!=0 || (arg->hasdefault & uTAGOF)!=0)) - free(arg->defvalue.size.symname); - assert(arg->tags!=NULL); - free(arg->tags); - } /* for */ - free(sym->dim.arglist); - if (sym->states!=NULL) { - delete_consttable(sym->states); - free(sym->states); - } /* if */ - } else if (sym->ident==iVARIABLE || sym->ident==iARRAY) { - if (sym->states!=NULL) { - delete_consttable(sym->states); - free(sym->states); - } /* if */ - } else if (sym->ident==iCONSTEXPR && (sym->usage & uENUMROOT)==uENUMROOT) { - /* free the constant list of an enum root */ - assert(sym->dim.enumlist!=NULL); - delete_consttable(sym->dim.enumlist); - free(sym->dim.enumlist); - } /* if */ - assert(sym->refer!=NULL); - free(sym->refer); - if (sym->documentation!=NULL) - free(sym->documentation); - free(sym); -} - -void delete_symbol(symbol *root,symbol *sym) -{ - symbol *origRoot=root; - /* find the symbol and its predecessor - * (this function assumes that you will never delete a symbol that is not - * in the table pointed at by "root") - */ - assert(root!=sym); - while (root->next!=sym) { - root=root->next; - assert(root!=NULL); - } /* while */ - - if (origRoot==&glbtab) - RemoveFromHashTable(sp_Globals, sym); - - /* unlink it, then free it */ - root->next=sym->next; - free_symbol(sym); -} - -int get_actual_compound(symbol *sym) -{ - if (sym->ident == iARRAY || sym->ident == iREFARRAY) { - while (sym->parent) - sym = sym->parent; - } - - return sym->compound; -} - -void delete_symbols(symbol *root,int level,int delete_labels,int delete_functions) -{ - symbol *origRoot=root; - symbol *sym,*parent_sym; - constvalue *stateptr; - int mustdelete; - - /* erase only the symbols with a deeper nesting level than the - * specified nesting level */ - while (root->next!=NULL) { - sym=root->next; - if (get_actual_compound(sym)ident) { - case iLABEL: - mustdelete=delete_labels; - break; - case iVARIABLE: - case iARRAY: - /* do not delete global variables if functions are preserved */ - mustdelete=delete_functions; - break; - case iREFERENCE: - /* always delete references (only exist as function parameters) */ - mustdelete=TRUE; - break; - case iREFARRAY: - /* a global iREFARRAY symbol is the return value of a function: delete - * this only if "globals" must be deleted; other iREFARRAY instances - * (locals) are also deleted - */ - mustdelete=delete_functions; - for (parent_sym=sym->parent; parent_sym!=NULL && parent_sym->ident!=iFUNCTN; parent_sym=parent_sym->parent) - assert(parent_sym->ident==iREFARRAY); - assert(parent_sym==NULL || (parent_sym->ident==iFUNCTN && parent_sym->parent==NULL)); - if (parent_sym==NULL || parent_sym->ident!=iFUNCTN) - mustdelete=TRUE; - break; - case iCONSTEXPR: - /* delete constants, except predefined constants */ - mustdelete=delete_functions || (sym->usage & uPREDEF)==0; - break; - case iFUNCTN: - /* optionally preserve globals (variables & functions), but - * NOT native functions - */ - mustdelete=delete_functions || (sym->usage & uNATIVE)!=0; - assert(sym->parent==NULL); - break; - case iMETHODMAP: - // We delete methodmap symbols at the end, but since methodmaps - // themselves get wiped, we null the pointer. - sym->methodmap = nullptr; - mustdelete = delete_functions; - assert(!sym->parent); - break; - case iARRAYCELL: - case iARRAYCHAR: - case iEXPRESSION: - case iVARARGS: - case iACCESSOR: - default: - assert(0); - break; - } /* switch */ - if (mustdelete) { - if (origRoot == &glbtab) - RemoveFromHashTable(sp_Globals, sym); - root->next=sym->next; - free_symbol(sym); - } else { - /* if the function was prototyped, but not implemented in this source, - * mark it as such, so that its use can be flagged - */ - if (sym->ident==iFUNCTN && (sym->usage & uDEFINE)==0) - sym->usage |= uMISSING; - if (sym->ident==iFUNCTN || sym->ident==iVARIABLE || sym->ident==iARRAY) - sym->usage &= ~uDEFINE; /* clear "defined" flag */ - /* set all states as "undefined" too */ - if (sym->states!=NULL) - for (stateptr=sym->states->next; stateptr!=NULL; stateptr=stateptr->next) - stateptr->value=0; - /* for user defined operators, also remove the "prototyped" flag, as - * user-defined operators *must* be declared before use - */ - if (sym->ident==iFUNCTN && !alpha(*sym->name)) - sym->usage &= ~uPROTOTYPED; - root=sym; /* skip the symbol */ - } /* if */ - } /* if */ -} - -static symbol *find_symbol(const symbol *root,const char *name,int fnumber,int automaton,int *cmptag) -{ - symbol *firstmatch=NULL; - symbol *sym=root->next; - int count=0; - unsigned long hash=NameHash(name); - while (sym!=NULL) { - if (hash==sym->hash && strcmp(name,sym->name)==0 /* check name */ - && (sym->parent==NULL || sym->ident==iCONSTEXPR) /* sub-types (hierarchical types) are skipped, except for enum fields */ - && (sym->fnumber<0 || sym->fnumber==fnumber)) /* check file number for scope */ - { - assert(sym->states==NULL || sym->states->next!=NULL); /* first element of the state list is the "root" */ - if (sym->ident==iFUNCTN - || (automaton<0 && sym->states==NULL) - || (automaton>=0 && sym->states!=NULL && state_getfsa(sym->states->next->index)==automaton)) - { - if (cmptag==NULL) - return sym; /* return first match */ - /* return closest match or first match; count number of matches */ - if (firstmatch==NULL) - firstmatch=sym; - assert(cmptag!=NULL); - if (*cmptag==0) - count++; - if (*cmptag==sym->tag) { - *cmptag=1; /* good match found, set number of matches to 1 */ - return sym; - } /* if */ - } /* if */ - } /* */ - sym=sym->next; - } /* while */ - if (cmptag!=NULL && firstmatch!=NULL) - *cmptag=count; - return firstmatch; -} - -static symbol *find_symbol_child(const symbol *root,const symbol *sym) -{ - symbol *ptr=root->next; - while (ptr!=NULL) { - if (ptr->parent==sym) - return ptr; - ptr=ptr->next; - } /* while */ - return NULL; -} - -/* Adds "bywhom" to the list of referrers of "entry". Typically, - * bywhom will be the function that uses a variable or that calls - * the function. - */ -int refer_symbol(symbol *entry,symbol *bywhom) -{ - int count; - - assert(bywhom!=NULL); /* it makes no sense to add a "void" referrer */ - assert(entry!=NULL); - assert(entry->refer!=NULL); - - /* see if it is already there */ - for (count=0; countnumrefers && entry->refer[count]!=bywhom; count++) - /* nothing */; - if (countnumrefers) { - assert(entry->refer[count]==bywhom); - return TRUE; - } /* if */ - - /* see if there is an empty spot in the referrer list */ - for (count=0; countnumrefers && entry->refer[count]!=NULL; count++) - /* nothing */; - assert(count <= entry->numrefers); - if (count==entry->numrefers) { - symbol **refer; - int newsize=2*entry->numrefers; - assert(newsize>0); - /* grow the referrer list */ - refer=(symbol**)realloc(entry->refer,newsize*sizeof(symbol*)); - if (refer==NULL) - return FALSE; /* insufficient memory */ - /* initialize the new entries */ - entry->refer=refer; - for (count=entry->numrefers; countrefer[count]=NULL; - count=entry->numrefers; /* first empty spot */ - entry->numrefers=newsize; - } /* if */ - - /* add the referrer */ - assert(entry->refer[count]==NULL); - entry->refer[count]=bywhom; - return TRUE; -} - -void markusage(symbol *sym,int usage) -{ - assert(sym!=NULL); - sym->usage |= (char)usage; - if ((usage & uWRITTEN)!=0) - sym->lnumber=fline; - /* check if (global) reference must be added to the symbol */ - if ((usage & (uREAD | uWRITTEN))!=0) { - /* only do this for global symbols */ - if (sym->vclass==sGLOBAL) { - /* "curfunc" should always be valid, since statements may not occurs - * outside functions; in the case of syntax errors, however, the - * compiler may arrive through this function - */ - if (curfunc!=NULL) - refer_symbol(sym,curfunc); - } /* if */ - } /* if */ -} - -/* findglb - * - * Returns a pointer to the global symbol (if found) or NULL (if not found) - */ -symbol *findglb(const char *name, int filter) -{ - /* find a symbol with a matching automaton first */ - symbol *sym=NULL; - - if (filter>sGLOBAL && sc_curstates>0) { - /* find a symbol whose state list matches the current fsa */ - sym=find_symbol(&glbtab,name,fcurrent,state_getfsa(sc_curstates),NULL); - if (sym!=NULL && sym->ident!=iFUNCTN) { - /* if sym!=NULL, we found a variable in the automaton; now we should - * also verify whether there is an intersection between the symbol's - * state list and the current state list - */ - assert(sym->states!=NULL && sym->states->next!=NULL); - if (!state_conflict_id(sc_curstates,sym->states->next->index)) - sym=NULL; - } /* if */ - } /* if */ - - /* if no symbol with a matching automaton exists, find a variable/function - * that has no state(s) attached to it - */ - if (sym==NULL) - sym=FindInHashTable(sp_Globals,name,fcurrent); - - return sym; -} - -/* findloc - * - * Returns a pointer to the local symbol (if found) or NULL (if not found). - * See add_symbol() how the deepest nesting level is searched first. - */ -symbol *findloc(const char *name) -{ - return find_symbol(&loctab,name,-1,-1,NULL); -} - -symbol *findconst(const char *name,int *cmptag) -{ - symbol *sym; - - sym=find_symbol(&loctab,name,-1,-1,cmptag); /* try local symbols first */ - if (sym==NULL || sym->ident!=iCONSTEXPR) { /* not found, or not a constant */ - if (cmptag) - sym=FindTaggedInHashTable(sp_Globals,name,fcurrent,cmptag); - else - sym=FindInHashTable(sp_Globals,name,fcurrent); - } - if (sym==NULL || sym->ident!=iCONSTEXPR) - return NULL; - assert(sym->parent==NULL || (sym->usage & uENUMFIELD)!=0); - /* ^^^ constants have no hierarchy, but enumeration fields may have a parent */ - return sym; -} - -symbol *finddepend(const symbol *parent) -{ - symbol *sym; - - sym=find_symbol_child(&loctab,parent); /* try local symbols first */ - if (sym==NULL) /* not found */ - sym=find_symbol_child(&glbtab,parent); - return sym; -} - -/* addsym - * - * Adds a symbol to the symbol table (either global or local variables, - * or global and local constants). - */ -symbol *addsym(const char *name,cell addr,int ident,int vclass,int tag,int usage) -{ - symbol entry, **refer; - - /* labels may only be defined once */ - assert(ident!=iLABEL || findloc(name)==NULL); - - /* create an empty referrer list */ - if ((refer=(symbol**)malloc(sizeof(symbol*)))==NULL) { - error(FATAL_ERROR_OOM); - return NULL; - } /* if */ - *refer=NULL; - - /* first fill in the entry */ - memset(&entry,0,sizeof entry); - strcpy(entry.name,name); - entry.hash=NameHash(name); - entry.addr=addr; - entry.codeaddr=code_idx; - entry.vclass=(char)vclass; - entry.ident=(char)ident; - entry.tag=tag; - entry.usage=(char)usage; - entry.fnumber=-1; /* assume global visibility (ignored for local symbols) */ - entry.lnumber=fline; - entry.numrefers=1; - entry.refer=refer; - - /* then insert it in the list */ - if (vclass==sGLOBAL) - return add_symbol(&glbtab,&entry,TRUE); - return add_symbol(&loctab,&entry,FALSE); -} - -symbol *addvariable(const char *name,cell addr,int ident,int vclass,int tag, - int dim[],int numdim,int idxtag[]) -{ - return addvariable2(name,addr,ident,vclass,tag,dim,numdim,idxtag,0); -} - -symbol *addvariable3(declinfo_t *decl,cell addr,int vclass,int slength) -{ - typeinfo_t *type = &decl->type; - return addvariable2( - decl->name, - addr, - type->ident, - vclass, - type->tag, - type->dim, - type->numdim, - type->idxtag, - slength - ); -} - -symbol *addvariable2(const char *name,cell addr,int ident,int vclass,int tag, - int dim[],int numdim,int idxtag[],int slength) -{ - symbol *sym; - - /* global variables may only be defined once - * One complication is that functions returning arrays declare an array - * with the same name as the function, so the assertion must allow for - * this special case. Another complication is that variables may be - * "redeclared" if they are local to an automaton (and findglb() will find - * the symbol without states if no symbol with states exists). - */ - assert(vclass!=sGLOBAL || (sym=findglb(name,sGLOBAL))==NULL || (sym->usage & uDEFINE)==0 - || (sym->ident==iFUNCTN && sym==curfunc) - || (sym->states==NULL && sc_curstates>0)); - - if (ident==iARRAY || ident==iREFARRAY) { - symbol *parent=NULL,*top; - int level; - sym=NULL; /* to avoid a compiler warning */ - for (level=0; leveldim.array.length=dim[level]; - if (tag == pc_tag_string && level == numdim - 1) { - if (slength == 0) - top->dim.array.length=dim[level] * sizeof(cell); - else - top->dim.array.slength=slength; - } else { - top->dim.array.slength=0; - } - top->dim.array.level=(short)(numdim-level-1); - top->x.tags.index=idxtag[level]; - top->parent=parent; - parent=top; - if (level==0) - sym=top; - } /* for */ - } else { - sym=addsym(name,addr,ident,vclass,tag,uDEFINE); - } /* if */ - return sym; -} - -/* getlabel - * - * Returns te next internal label number. The global variable sc_labnum is - * initialized to zero. - */ -int getlabel(void) -{ - return sc_labnum++; -} - -/* itoh - * - * Converts a number to a hexadecimal string and returns a pointer to that - * string. This function is NOT re-entrant. - */ -char *itoh(ucell val) -{ -static char itohstr[30]; - char *ptr; - int i,nibble[16]; /* a 64-bit hexadecimal cell has 16 nibbles */ - int max; - - #if PAWN_CELL_SIZE==16 - max=4; - #elif PAWN_CELL_SIZE==32 - max=8; - #elif PAWN_CELL_SIZE==64 - max=16; - #else - #error Unsupported cell size - #endif - ptr=itohstr; - for (i=0; i>=4; - } /* endfor */ - i=max-1; - while (nibble[i]==0 && i>0) /* search for highest non-zero nibble */ - i-=1; - while (i>=0){ - if (nibble[i]>=10) - *ptr++=(char)('a'+(nibble[i]-10)); - else - *ptr++=(char)('0'+nibble[i]); - i-=1; - } /* while */ - *ptr='\0'; /* and a zero-terminator */ - return itohstr; -} - -int lextok(token_t *tok) -{ - tok->id = lex(&tok->val, &tok->str); - return tok->id; -} - -int expecttoken(int id, token_t *tok) -{ - int rval = needtoken(id); - if (rval) { - tok->val = current_token()->value; - tok->id = current_token()->id; - tok->str = current_token()->str; - return rval; - } - return FALSE; -} - -int matchtoken2(int id, token_t *tok) -{ - if (matchtoken(id)) { - tok->id = tokeninfo(&tok->val, &tok->str); - return TRUE; - } - return FALSE; -} - -int matchsymbol(token_ident_t *ident) -{ - if (lextok(&ident->tok) != tSYMBOL) { - lexpush(); - return FALSE; - } - strcpy(ident->name, ident->tok.str); - ident->tok.str = ident->name; - return TRUE; -} - -int needsymbol(token_ident_t *ident) -{ - if (!expecttoken(tSYMBOL, &ident->tok)) - return FALSE; - strcpy(ident->name, ident->tok.str); - ident->tok.str = ident->name; - return TRUE; -} diff --git a/sourcepawn/compiler/sc3.cpp b/sourcepawn/compiler/sc3.cpp deleted file mode 100644 index d247978e..00000000 --- a/sourcepawn/compiler/sc3.cpp +++ /dev/null @@ -1,3267 +0,0 @@ -/* vim: set ts=8 sts=2 sw=2 tw=99 et: */ -/* Pawn compiler - Recursive descend expresion parser - * - * Copyright (c) ITB CompuPhase, 1997-2005 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not reeq;quired. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include -#include /* for _MAX_PATH */ -#include -#if defined FORTIFY - #include -#endif -#include "sc.h" -#include "sctracker.h" - -static int skim(int *opstr,void (*testfunc)(int),int dropval,int endval, - int (*hier)(value*),value *lval); -static void dropout(int lvalue,void (*testfunc)(int val),int exit1,value *lval); -static int plnge(int *opstr,int opoff,int (*hier)(value *lval),value *lval, - const char *forcetag,int chkbitwise); -static int plnge1(int (*hier)(value *lval),value *lval); -static void plnge2(void (*oper)(void), - int (*hier)(value *lval), - value *lval1,value *lval2); -static cell calc(cell left,void (*oper)(),cell right,char *boolresult); -static int hier14(value *lval); -static int hier13(value *lval); -static int hier12(value *lval); -static int hier11(value *lval); -static int hier10(value *lval); -static int hier9(value *lval); -static int hier8(value *lval); -static int hier7(value *lval); -static int hier6(value *lval); -static int hier5(value *lval); -static int hier4(value *lval); -static int hier3(value *lval); -static int hier2(value *lval); -static int hier1(value *lval1); -static int primary(value *lval); -static void clear_value(value *lval); -static void callfunction(symbol *sym, const svalue *implicitthis, value *lval_result, int matchparanthesis); -static int dbltest(void (*oper)(),value *lval1,value *lval2); -static int commutative(void (*oper)()); -static int constant(value *lval); - -static char lastsymbol[sNAMEMAX+1]; /* name of last function/variable */ -static int bitwise_opercount; /* count of bitwise operators in an expression */ - -/* Function addresses of binary operators for signed operations */ -static void (*op1[17])(void) = { - os_mult,os_div,os_mod, /* hier3, index 0 */ - ob_add,ob_sub, /* hier4, index 3 */ - ob_sal,os_sar,ou_sar, /* hier5, index 5 */ - ob_and, /* hier6, index 8 */ - ob_xor, /* hier7, index 9 */ - ob_or, /* hier8, index 10 */ - os_le,os_ge,os_lt,os_gt, /* hier9, index 11 */ - ob_eq,ob_ne, /* hier10, index 15 */ -}; -/* These two functions are defined because the functions inc() and dec() in - * SC4.C have a different prototype than the other code generation functions. - * The arrays for user-defined functions use the function pointers for - * identifying what kind of operation is requested; these functions must all - * have the same prototype. As inc() and dec() are special cases already, it - * is simplest to add two "do-nothing" functions. - */ -static void user_inc(void) {} -static void user_dec(void) {} - -/* - * Searches for a binary operator a list of operators. The list is stored in - * the array "list". The last entry in the list should be set to 0. - * - * The index of an operator in "list" (if found) is returned in "opidx". If - * no operator is found, nextop() returns 0. - * - * If an operator is found in the expression, it cannot be used in a function - * call with omitted parantheses. Mark this... - * - * Global references: sc_allowproccall (modified) - */ -static int nextop(int *opidx,int *list) -{ - *opidx=0; - while (*list){ - if (matchtoken(*list)){ - sc_allowproccall=FALSE; - return TRUE; /* found! */ - } else { - list+=1; - *opidx+=1; - } /* if */ - } /* while */ - return FALSE; /* entire list scanned, nothing found */ -} - -int check_userop(void (*oper)(void),int tag1,int tag2,int numparam, - value *lval,int *resulttag) -{ - static const char *binoperstr[] = { - "*", "/", "%", "+", "-", "", "", "", - "", "", "", "<=", ">=", "<", ">", "==", "!=" - }; - static int binoper_savepri[] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, - FALSE, FALSE, FALSE, FALSE, FALSE, - TRUE, TRUE, TRUE, TRUE, FALSE, FALSE - }; - static const char *unoperstr[] = { "!", "-", "++", "--" }; - static void (*unopers[])(void) = { lneg, neg, user_inc, user_dec }; - - char opername[4] = "", symbolname[sNAMEMAX+1]; - int i,swapparams,savepri,savealt; - int paramspassed; - symbol *sym; - - /* since user-defined operators on untagged operands are forbidden, we have - * a quick exit. - */ - assert(numparam==1 || numparam==2); - if (tag1==0 && (numparam==1 || tag2==0)) - return FALSE; - - savepri=savealt=FALSE; - /* find the name with the operator */ - if (numparam==2) { - if (oper==NULL) { - /* assignment operator: a special case */ - strcpy(opername,"="); - if (lval!=NULL && (lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR)) - savealt=TRUE; - } else { - assert( (sizeof binoperstr / sizeof binoperstr[0]) == (sizeof op1 / sizeof op1[0]) ); - for (i=0; iusage & uDEFINE)==0*/) { /* ??? should not check uDEFINE; first pass clears these bits */ - /* check for commutative operators */ - if (tag1==tag2 || oper==NULL || !commutative(oper)) - return FALSE; /* not commutative, cannot swap operands */ - /* if arrived here, the operator is commutative and the tags are different, - * swap tags and try again - */ - assert(numparam==2); /* commutative operator must be a binary operator */ - operator_symname(symbolname,opername,tag2,tag1,numparam,tag1); - swapparams=TRUE; - sym=findglb(symbolname,sGLOBAL); - if (sym==NULL /*|| (sym->usage & uDEFINE)==0*/) - return FALSE; - } /* if */ - - /* check existance and the proper declaration of this function */ - if ((sym->usage & uMISSING)!=0 || (sym->usage & uPROTOTYPED)==0) { - char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ - funcdisplayname(symname,sym->name); - if ((sym->usage & uMISSING)!=0) - error(4,symname); /* function not defined */ - if ((sym->usage & uPROTOTYPED)==0) - error(71,symname); /* operator must be declared before use */ - } /* if */ - - /* we don't want to use the redefined operator in the function that - * redefines the operator itself, otherwise the snippet below gives - * an unexpected recursion: - * fixed:operator+(fixed:a, fixed:b) - * return a + b - */ - if (sym==curfunc) - return FALSE; - - /* for increment and decrement operators, the symbol must first be loaded - * (and stored back afterwards) - */ - if (oper==user_inc || oper==user_dec) { - assert(!savepri); - assert(lval!=NULL); - if (lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR) - pushreg(sPRI); /* save current address in PRI */ - if (lval->ident!=iACCESSOR) - rvalue(lval); /* get the symbol's value in PRI */ - } /* if */ - - assert(!savepri || !savealt); /* either one MAY be set, but not both */ - if (savepri) { - /* the chained comparison operators require that the ALT register is - * unmodified, so we save it here; actually, we save PRI because the normal - * instruction sequence (without user operator) swaps PRI and ALT - */ - pushreg(sPRI); /* right-hand operand is in PRI */ - } else if (savealt) { - /* for the assignment operator, ALT may contain an address at which the - * result must be stored; this address must be preserved accross the - * call - */ - assert(lval!=NULL); /* this was checked earlier */ - assert(lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR); /* checked earlier */ - pushreg(sALT); - } /* if */ - - /* push parameters, call the function */ - paramspassed= (oper==NULL) ? 1 : numparam; - switch (paramspassed) { - case 1: - pushreg(sPRI); - break; - case 2: - /* note that 1) a function expects that the parameters are pushed - * in reversed order, and 2) the left operand is in the secondary register - * and the right operand is in the primary register */ - if (swapparams) { - pushreg(sALT); - pushreg(sPRI); - } else { - pushreg(sPRI); - pushreg(sALT); - } /* if */ - break; - default: - assert(0); - } /* switch */ - markexpr(sPARM,NULL,0); /* mark the end of a sub-expression */ - pushval((cell)paramspassed /* *sizeof(cell)*/ ); - assert(sym->ident==iFUNCTN); - ffcall(sym,NULL,paramspassed); - if (sc_status!=statSKIP) - markusage(sym,uREAD); /* do not mark as "used" when this call itself is skipped */ - if ((sym->usage & uNATIVE)!=0 && sym->x.lib!=NULL) - sym->x.lib->value += 1; /* increment "usage count" of the library */ - sideeffect=TRUE; /* assume functions carry out a side-effect */ - assert(resulttag!=NULL); - *resulttag=sym->tag; /* save tag of the called function */ - - if (savepri || savealt) - popreg(sALT); /* restore the saved PRI/ALT that into ALT */ - if (oper==user_inc || oper==user_dec) { - assert(lval!=NULL); - if (lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR) - popreg(sALT); /* restore address (in ALT) */ - if (lval->ident!=iACCESSOR) { - store(lval); /* store PRI in the symbol */ - moveto1(); /* make sure PRI is restored on exit */ - } - } /* if */ - return TRUE; -} - -int checktags_string(int tags[], int numtags, value *sym1) -{ - int i; - if (sym1->ident == iARRAY || sym1->ident == iREFARRAY) - { - return FALSE; - } - for (i=0; itag == pc_tag_string && tags[i] == 0) || - (sym1->tag == 0 && tags[i] == pc_tag_string)) - return TRUE; - } - return FALSE; -} - -int checktag_string(value *sym1, value *sym2) -{ - if (sym1->ident == iARRAY || sym2->ident == iARRAY || - sym1->ident == iREFARRAY || sym2->ident == iREFARRAY) - { - return FALSE; - } - if ((sym1->tag == pc_tag_string && sym2->tag == 0) || - (sym1->tag == 0 && sym2->tag == pc_tag_string)) - { - return TRUE; - } - - return FALSE; -} - -const char *type_to_name(int tag) -{ - if (tag == 0) - return "int"; - if (tag == sc_rationaltag) - return "float"; - if (tag == pc_tag_string) - return "char"; - if (tag == pc_anytag) - return "any"; - - const char *name = pc_tagname(tag); - if (name) - return name; - - if (tag & FUNCTAG) - return "function"; - return "unknown"; -} - -int matchtag_string(int ident, int tag) -{ - if (ident == iARRAY || ident == iREFARRAY) - return FALSE; - return (tag == pc_tag_string) ? TRUE : FALSE; -} - -static int obj_typeerror(int id, int tag1, int tag2) -{ - const char *left = pc_tagname(tag1); - const char *right = pc_tagname(tag2); - if (!left || strcmp(left, "_") == 0) - left = "int"; - if (!right || strcmp(right, "_") == 0) - right = "int"; - error(id, right, left); - return FALSE; -} - -static int matchobjecttags(int formaltag, int actualtag, int flags) -{ - if ((flags & MATCHTAG_COMMUTATIVE) && - (formaltag == pc_tag_null_t || formaltag == pc_tag_nullfunc_t)) - { - // Bypass the check immediately after for non-object coercion. - int tmp = actualtag; - actualtag = formaltag; - formaltag = tmp; - } - - // objects never coerce to non-objects, YET. - if ((formaltag & OBJECTTAG) && !(actualtag & OBJECTTAG)) - return obj_typeerror(132, formaltag, actualtag); - - if (actualtag == pc_tag_nullfunc_t) { - // All functions are nullable. We use a separate constant for backward - // compatibility; plugins and extensions check -1, not 0. - if (formaltag & FUNCTAG) - return TRUE; - - error(154, pc_tagname(formaltag)); - return FALSE; - } - - if (actualtag == pc_tag_null_t) { - // All objects are nullable. - if (formaltag & OBJECTTAG) - return TRUE; - - // Some methodmaps are nullable. The nullable property is inherited - // automatically. - methodmap_t *map = methodmap_find_by_tag(formaltag); - if (map && map->nullable) - return TRUE; - - error(148, pc_tagname(formaltag)); - return FALSE; - } - - if (!(formaltag & OBJECTTAG) && (actualtag & OBJECTTAG)) - return obj_typeerror(131, formaltag, actualtag); - - // Every object coerces to "object". - if (formaltag == pc_tag_object) - return TRUE; - - if (flags & MATCHTAG_COERCE) - return obj_typeerror(134, formaltag, actualtag); - - methodmap_t *map = methodmap_find_by_tag(actualtag); - for (; map; map = map->parent) { - if (map->tag == formaltag) - return TRUE; - } - - return obj_typeerror(133, formaltag, actualtag); -} - -static int matchreturntag(const functag_t *formal, const functag_t *actual) -{ - if (formal->ret_tag == actual->ret_tag) - return TRUE; - if (formal->ret_tag == pc_tag_void) { - if (actual->ret_tag == 0 && !(actual->usage & uRETVALUE)) - return TRUE; - } - return FALSE; -} - -static int funcarg_compare(const funcarg_t *formal, const funcarg_t *actual) -{ - // Check type. - if (actual->ident != formal->ident) - return FALSE; - - // Check rank. - if (actual->dimcount != formal->dimcount) - return FALSE; - - // Check arity. - for (int i = 0; i < formal->dimcount; i++) { - if (actual->dims[i] != formal->dims[i]) - return FALSE; - } - - // Check tags. - if (actual->tagcount != formal->tagcount) - return FALSE; - for (int i = 0; i < formal->tagcount; i++) { - // Note we invert the order we pass things to matchtag() here. If the - // typedef specifies base type X, and the function specifies derived - // type Y, we want this to type since such an assignment is valid. - // - // Most programming languages do not subtype arguments like this. We do - // it in SourcePawn to preserve compatibility during the Transitional - // Syntax effort. - int actual_tag = actual->tags[i]; - int formal_tag = formal->tags[i]; - if (!matchtag(actual_tag, formal_tag, MATCHTAG_SILENT|MATCHTAG_COERCE)) - return FALSE; - } - - return TRUE; -} - -static int functag_compare(const functag_t *formal, const functag_t *actual) -{ - // Check return types. - if (!matchreturntag(formal, actual)) - return FALSE; - - // Make sure there are no trailing arguments. - if (actual->argcount > formal->argcount) - return FALSE; - - // Check arguments. - for (int i = 0; i < formal->argcount; i++) { - const funcarg_t *formal_arg = &formal->args[i]; - - if (i >= actual->argcount) { - if (formal_arg->ommittable) - return TRUE; - return FALSE; - } - - const funcarg_t *actual_arg = &actual->args[i]; - if (!funcarg_compare(formal_arg, actual_arg)) - return FALSE; - } - - return TRUE; -} - -static int matchfunctags(int formaltag, int actualtag) -{ - if (formaltag == pc_functag && (actualtag & FUNCTAG)) - return TRUE; - - if (actualtag == pc_tag_nullfunc_t) - return TRUE; - - if (!(actualtag & FUNCTAG)) - return FALSE; - - functag_t *actual = functag_find_intrinsic(actualtag); - if (!actual) - return FALSE; - - funcenum_t *e = funcenums_find_by_tag(formaltag); - if (!e) - return FALSE; - - for (functag_t *formal = e->first; formal; formal = formal->next) { - if (functag_compare(formal, actual)) - return TRUE; - } - - return FALSE; -} - -int matchtag(int formaltag, int actualtag, int flags) -{ - if (formaltag == actualtag) - return TRUE; - - if ((formaltag & OBJECTTAG) || (actualtag & OBJECTTAG)) - return matchobjecttags(formaltag, actualtag, flags); - - if ((actualtag & FUNCTAG) && !(formaltag & FUNCTAG)) { - // We're being given a function, but the destination is not a function. - error(130); - return FALSE; - } - - /* if the formal tag is zero and the actual tag is not "fixed", the actual - * tag is "coerced" to zero - */ - if ((flags & MATCHTAG_COERCE) && !formaltag && !(actualtag & FIXEDTAG)) - return TRUE; - - if (formaltag == pc_anytag || actualtag == pc_anytag) - return TRUE; - - if (formaltag & FUNCTAG) { - if (!matchfunctags(formaltag, actualtag)) { - error(100); - return FALSE; - } - return TRUE; - } - - if (flags & (MATCHTAG_COERCE|MATCHTAG_DEDUCE)) { - // See if the tag has a methodmap associated with it. If so, see if the given - // tag is anywhere on the inheritance chain. - methodmap_t *map = methodmap_find_by_tag(actualtag); - if (map) { - for (; map; map = map->parent) { - if (map->tag == formaltag) - return TRUE; - } - } - } - - if (!(flags & MATCHTAG_SILENT)) - error(213); - return FALSE; -} - -/* - * The AMX pseudo-processor has no direct support for logical (boolean) - * operations. These have to be done via comparing and jumping. Since we are - * already jumping through the code, we might as well implement an "early - * drop-out" evaluation (also called "short-circuit"). This conforms to - * standard C: - * - * expr1 || expr2 expr2 will only be evaluated if expr1 is false. - * expr1 && expr2 expr2 will only be evaluated if expr1 is true. - * - * expr1 || expr2 && expr3 expr2 will only be evaluated if expr1 is false - * and expr3 will only be evaluated if expr1 is - * false and expr2 is true. - * - * Code generation for the last example proceeds thus: - * - * evaluate expr1 - * operator || found - * jump to "l1" if result of expr1 not equal to 0 - * evaluate expr2 - * -> operator && found; skip to higher level in hierarchy diagram - * jump to "l2" if result of expr2 equal to 0 - * evaluate expr3 - * jump to "l2" if result of expr3 equal to 0 - * set expression result to 1 (true) - * jump to "l3" - * l2: set expression result to 0 (false) - * l3: - * <- drop back to previous hierarchy level - * jump to "l1" if result of expr2 && expr3 not equal to 0 - * set expression result to 0 (false) - * jump to "l4" - * l1: set expression result to 1 (true) - * l4: - * - */ - -/* Skim over terms adjoining || and && operators - * dropval The value of the expression after "dropping out". An "or" drops - * out when the left hand is TRUE, so dropval must be 1 on "or" - * expressions. - * endval The value of the expression when no expression drops out. In an - * "or" expression, this happens when both the left hand and the - * right hand are FALSE, so endval must be 0 for "or" expressions. - */ -static int skim(int *opstr,void (*testfunc)(int),int dropval,int endval, - int (*hier)(value*),value *lval) -{ - int lvalue,hits,droplab,endlab,opidx; - int allconst,foundop; - cell constval; - int index; - cell cidx; - - stgget(&index,&cidx); /* mark position in code generator */ - hits=FALSE; /* no logical operators "hit" yet */ - allconst=TRUE; /* assume all values "const" */ - constval=0; - droplab=0; /* to avoid a compiler warning */ - for ( ;; ) { - lvalue=plnge1(hier,lval); /* evaluate left expression */ - - allconst= allconst && (lval->ident==iCONSTEXPR); - if (allconst) { - if (hits) { - /* one operator was already found */ - if (testfunc==jmp_ne0) - lval->constval= lval->constval || constval; - else - lval->constval= lval->constval && constval; - } /* if */ - constval=lval->constval; /* save result accumulated so far */ - } /* if */ - - foundop=nextop(&opidx,opstr); - if ((foundop || hits) && (lval->ident==iARRAY || lval->ident==iREFARRAY)) - error(33, lval->sym ? lval->sym->name : "-unknown-"); /* array was not indexed in an expression */ - if (foundop) { - if (!hits) { - /* this is the first operator in the list */ - hits=TRUE; - droplab=getlabel(); - } /* if */ - dropout(lvalue,testfunc,droplab,lval); - } else if (hits) { /* no (more) identical operators */ - dropout(lvalue,testfunc,droplab,lval); /* found at least one operator! */ - ldconst(endval,sPRI); - jumplabel(endlab=getlabel()); - setlabel(droplab); - ldconst(dropval,sPRI); - setlabel(endlab); - lval->sym=NULL; - lval->tag=pc_addtag("bool"); /* force tag to be "bool" */ - if (allconst) { - lval->ident=iCONSTEXPR; - lval->constval=constval; - stgdel(index,cidx); /* scratch generated code and calculate */ - } else { - lval->ident=iEXPRESSION; - lval->constval=0; - } /* if */ - return FALSE; - } else { - return lvalue; /* none of the operators in "opstr" were found */ - } /* if */ - - } /* while */ -} - -/* - * Reads into the primary register the variable pointed to by lval if - * plunging through the hierarchy levels detected an lvalue. Otherwise - * if a constant was detected, it is loaded. If there is no constant and - * no lvalue, the primary register must already contain the expression - * result. - * - * After that, the compare routines "jmp_ne0" or "jmp_eq0" are called, which - * compare the primary register against 0, and jump to the "early drop-out" - * label "exit1" if the condition is true. - */ -static void dropout(int lvalue,void (*testfunc)(int val),int exit1,value *lval) -{ - if (lvalue) - rvalue(lval); - else if (lval->ident==iCONSTEXPR) - ldconst(lval->constval,sPRI); - (*testfunc)(exit1); -} - -static void checkfunction(value *lval) -{ - symbol *sym=lval->sym; - - if (sym==NULL || (sym->ident!=iFUNCTN && sym->ident!=iREFFUNC)) - return; /* no known symbol, or not a function result */ - - if ((sym->usage & uDEFINE)!=0) { - /* function is defined, can now check the return value (but make an - * exception for directly recursive functions) - */ - if (sym!=curfunc && (sym->usage & uRETVALUE)==0) { - char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ - funcdisplayname(symname,sym->name); - error(209,symname); /* function should return a value */ - } /* if */ - } else { - /* function not yet defined, set */ - sym->usage|=uRETVALUE; /* make sure that a future implementation of - * the function uses "return " */ - } /* if */ -} - -/* - * Plunge to a lower level - */ -static int plnge(int *opstr,int opoff,int (*hier)(value *lval),value *lval, - const char *forcetag,int chkbitwise) -{ - int lvalue,opidx; - int count; - value lval2 = {0}; - - lvalue=plnge1(hier,lval); - if (nextop(&opidx,opstr)==0) - return lvalue; /* no operator in "opstr" found */ - if (lvalue) - rvalue(lval); - count=0; - do { - if (chkbitwise && count++>0 && bitwise_opercount!=0) - error(212); - opidx+=opoff; /* add offset to index returned by nextop() */ - plnge2(op1[opidx],hier,lval,&lval2); - if (op1[opidx]==ob_and || op1[opidx]==ob_or) - bitwise_opercount++; - if (forcetag!=NULL) - lval->tag=pc_addtag(forcetag); - } while (nextop(&opidx,opstr)); /* do */ - return FALSE; /* result of expression is not an lvalue */ -} - -/* plnge_rel - * - * Binary plunge to lower level; this is very simular to plnge, but - * it has special code generation sequences for chained operations. - */ -static int plnge_rel(int *opstr,int opoff,int (*hier)(value *lval),value *lval) -{ - int lvalue,opidx; - value lval2={0}; - int count; - char boolresult; - - /* this function should only be called for relational operators */ - assert(op1[opoff]==os_le); - lvalue=plnge1(hier,lval); - if (nextop(&opidx,opstr)==0) - return lvalue; /* no operator in "opstr" found */ - if (lvalue) - rvalue(lval); - count=0; - lval->boolresult=TRUE; - do { - /* same check as in plnge(), but "chkbitwise" is always TRUE */ - if (count>0 && bitwise_opercount!=0) - error(212); - if (count>0) { - relop_prefix(); - boolresult=lval->boolresult; - *lval=lval2; /* copy right hand expression of the previous iteration */ - lval->boolresult=boolresult; - } /* if */ - opidx+=opoff; - plnge2(op1[opidx],hier,lval,&lval2); - if (count++>0) - relop_suffix(); - } while (nextop(&opidx,opstr)); /* enddo */ - lval->constval=lval->boolresult; - lval->tag=pc_addtag("bool"); /* force tag to be "bool" */ - return FALSE; /* result of expression is not an lvalue */ -} - -/* plnge1 - * - * Unary plunge to lower level - * Called by: skim(), plnge(), plnge2(), plnge_rel(), hier14() and hier13() - */ -static int plnge1(int (*hier)(value *lval),value *lval) -{ - int lvalue,index; - cell cidx; - - stgget(&index,&cidx); /* mark position in code generator */ - lvalue=(*hier)(lval); - if (lval->ident==iCONSTEXPR) - stgdel(index,cidx); /* load constant later */ - return lvalue; -} - -/* plnge2 - * - * Binary plunge to lower level - * Called by: plnge(), plnge_rel(), hier14() and hier1() - */ -static void plnge2(void (*oper)(void), - int (*hier)(value *lval), - value *lval1,value *lval2) -{ - int index; - cell cidx; - - stgget(&index,&cidx); /* mark position in code generator */ - if (lval1->ident==iCONSTEXPR) { /* constant on left side; it is not yet loaded */ - if (plnge1(hier,lval2)) - rvalue(lval2); /* load lvalue now */ - else if (lval2->ident==iCONSTEXPR) - ldconst(lval2->constval<constval<ident==iCONSTEXPR) { /* constant on right side */ - if (commutative(oper)) { /* test for commutative operators */ - value lvaltmp = {0}; - stgdel(index,cidx); /* scratch pushreg() and constant fetch (then - * fetch the constant again */ - ldconst(lval2->constval<constval<ident==iARRAY || lval1->ident==iREFARRAY) { - const char *ptr=(lval1->sym!=NULL) ? lval1->sym->name : "-unknown-"; - error(33,ptr); /* array must be indexed */ - } else if (lval2->ident==iARRAY || lval2->ident==iREFARRAY) { - const char *ptr=(lval2->sym!=NULL) ? lval2->sym->name : "-unknown-"; - error(33,ptr); /* array must be indexed */ - } /* if */ - /* ??? ^^^ should do same kind of error checking with functions */ - - /* check whether an "operator" function is defined for the tag names - * (a constant expression cannot be optimized in that case) - */ - if (check_userop(oper,lval1->tag,lval2->tag,2,NULL,&lval1->tag)) { - lval1->ident=iEXPRESSION; - lval1->constval=0; - } else if (lval1->ident==iCONSTEXPR && lval2->ident==iCONSTEXPR) { - /* only constant expression if both constant */ - stgdel(index,cidx); /* scratch generated code and calculate */ - matchtag(lval1->tag,lval2->tag,FALSE); - lval1->constval=calc(lval1->constval,oper,lval2->constval,&lval1->boolresult); - } else { - // For the purposes of tag matching, we consider the order to be irrelevant. - if (!checktag_string(lval1, lval2)) - matchtag(lval1->tag, lval2->tag, MATCHTAG_COMMUTATIVE|MATCHTAG_DEDUCE); - (*oper)(); /* do the (signed) operation */ - lval1->ident=iEXPRESSION; - } /* if */ - } /* if */ -} - -static cell flooreddiv(cell a,cell b,int return_remainder) -{ - cell q,r; - - if (b==0) { - error(29); - return 0; - } /* if */ - /* first implement truncated division in a portable way */ - #define IABS(a) ((a)>=0 ? (a) : (-a)) - q=IABS(a)/IABS(b); - if ((cell)(a ^ b)<0) - q=-q; /* swap sign if either "a" or "b" is negative (but not both) */ - r=a-q*b; /* calculate the matching remainder */ - /* now "fiddle" with the values to get floored division */ - if (r!=0 && (cell)(r ^ b)<0) { - q--; - r+=b; - } /* if */ - return return_remainder ? r : q; -} - -static cell calc(cell left,void (*oper)(),cell right,char *boolresult) -{ - if (oper==ob_or) - return (left | right); - else if (oper==ob_xor) - return (left ^ right); - else if (oper==ob_and) - return (left & right); - else if (oper==ob_eq) - return (left == right); - else if (oper==ob_ne) - return (left != right); - else if (oper==os_le) - return *boolresult &= (char)(left <= right), right; - else if (oper==os_ge) - return *boolresult &= (char)(left >= right), right; - else if (oper==os_lt) - return *boolresult &= (char)(left < right), right; - else if (oper==os_gt) - return *boolresult &= (char)(left > right), right; - else if (oper==os_sar) - return (left >> (int)right); - else if (oper==ou_sar) - return ((ucell)left >> (ucell)right); - else if (oper==ob_sal) - return ((ucell)left << (int)right); - else if (oper==ob_add) - return (left + right); - else if (oper==ob_sub) - return (left - right); - else if (oper==os_mult) - return (left * right); - else if (oper==os_div) - return flooreddiv(left,right,0); - else if (oper==os_mod) - return flooreddiv(left,right,1); - else - error(29); /* invalid expression, assumed 0 (this should never occur) */ - return 0; -} - -int lvalexpr(svalue *sval) -{ - memset(sval, 0, sizeof(*sval)); - - errorset(sEXPRMARK, 0); - pushheaplist(); - sval->lvalue = hier14(&sval->val); - popheaplist(); - errorset(sEXPRRELEASE, 0); - - return sval->val.ident; -} - -int expression(cell *val,int *tag,symbol **symptr,int chkfuncresult,value *_lval) -{ - value lval={0}; - pushheaplist(); - - if (hier14(&lval)) - rvalue(&lval); - /* scrap any arrays left on the heap */ - popheaplist(); - - if (lval.ident==iCONSTEXPR && val!=NULL) /* constant expression */ - *val=lval.constval; - if (tag!=NULL) - *tag=lval.tag; - if (symptr!=NULL) - *symptr=lval.sym; - if (chkfuncresult) - checkfunction(&lval); - if (_lval) - *_lval=lval; - return lval.ident; -} - -int sc_getstateid(constvalue **automaton,constvalue **state) -{ - char name[sNAMEMAX+1]; - cell val; - char *str; - int fsa,islabel; - - assert(automaton!=NULL); - assert(state!=NULL); - if (!(islabel=matchtoken(tLABEL)) && !needtoken(tSYMBOL)) - return 0; - - tokeninfo(&val,&str); - assert(strlen(str)index>0); - assert(strlen(str)index==0); - } /* if */ - assert(*automaton!=NULL); - fsa=(*automaton)->index; - - assert(*automaton!=NULL); - *state=state_find(name,fsa); - if (*state==NULL) { - const char *fsaname=(*automaton)->name; - if (*fsaname=='\0') - fsaname="

"; - error(87,name,fsaname); /* unknown state for automaton */ - return 0; - } /* if */ - - return 1; -} - -cell array_totalsize(symbol *sym) -{ - cell length; - - assert(sym!=NULL); - assert(sym->ident==iARRAY || sym->ident==iREFARRAY); - length=sym->dim.array.length; - if (sym->dim.array.level > 0) { - cell sublength=array_totalsize(finddepend(sym)); - if (sublength>0) - length=length+length*sublength; - else - length=0; - } /* if */ - return length; -} - -static cell array_levelsize(symbol *sym,int level) -{ - assert(sym!=NULL); - assert(sym->ident==iARRAY || sym->ident==iREFARRAY); - assert(level <= sym->dim.array.level); - while (level-- > 0) { - sym=finddepend(sym); - assert(sym!=NULL); - } /* if */ - return (sym->dim.array.slength ? sym->dim.array.slength : sym->dim.array.length); -} - -/* hier14 - * - * Lowest hierarchy level (except for the , operator). - * - * Global references: sc_intest (reffered to only) - * sc_allowproccall (modified) - */ -static int hier14(value *lval1) -{ - int lvalue; - value lval2={0},lval3={0}; - void (*oper)(void); - int tok,level,i; - cell val; - char *st; - int bwcount,leftarray; - cell arrayidx1[sDIMEN_MAX],arrayidx2[sDIMEN_MAX]; /* last used array indices */ - cell *org_arrayidx; - - bwcount=bitwise_opercount; - bitwise_opercount=0; - /* initialize the index arrays with unlikely constant indices; note that - * these indices will only be changed when the array is indexed with a - * constant, and that negative array indices are invalid (so actually, any - * negative value would do). - */ - for (i=0; iarrayidx; /* save current pointer, to reset later */ - if (lval1->arrayidx==NULL) - lval1->arrayidx=arrayidx1; - lvalue=plnge1(hier13,lval1); - if (lval1->ident!=iARRAYCELL && lval1->ident!=iARRAYCHAR) - lval1->arrayidx=NULL; - if (lval1->ident==iCONSTEXPR) /* load constant here */ - ldconst(lval1->constval,sPRI); - tok=lex(&val,&st); - switch (tok) { - case taOR: - oper=ob_or; - break; - case taXOR: - oper=ob_xor; - break; - case taAND: - oper=ob_and; - break; - case taADD: - oper=ob_add; - break; - case taSUB: - oper=ob_sub; - break; - case taMULT: - oper=os_mult; - break; - case taDIV: - oper=os_div; - break; - case taMOD: - oper=os_mod; - break; - case taSHRU: - oper=ou_sar; - break; - case taSHR: - oper=os_sar; - break; - case taSHL: - oper=ob_sal; - break; - case '=': /* simple assignment */ - oper=NULL; - if (sc_intest) - error(211); /* possibly unintended assignment */ - break; - default: - lexpush(); - bitwise_opercount=bwcount; - lval1->arrayidx=org_arrayidx; /* restore array index pointer */ - return lvalue; - } /* switch */ - - /* if we get here, it was an assignment; first check a few special cases - * and then the general */ - if (lval1->ident==iARRAYCHAR) { - /* special case, assignment to packed character in a cell is permitted */ - lvalue=TRUE; - } else if (lval1->ident==iARRAY || lval1->ident==iREFARRAY) { - /* array assignment is permitted too (with restrictions) */ - if (oper) - return error(23); /* array assignment must be simple assigment */ - assert(lval1->sym!=NULL); - if (array_totalsize(lval1->sym)==0) - return error(46,lval1->sym->name); /* unknown array size */ - lvalue=TRUE; - } /* if */ - - /* operand on left side of assignment must be lvalue */ - if (!lvalue) - return error(22); /* must be lvalue */ - /* may not change "constant" parameters */ - assert(lval1->sym || lval1->accessor); - if (lval1->sym && (lval1->sym->usage & uCONST) != 0) - return error(22); /* assignment to const argument */ - sc_allowproccall=FALSE; /* may no longer use "procedure call" syntax */ - - lval3=*lval1; /* save symbol to enable storage of expresion result */ - lval1->arrayidx=org_arrayidx; /* restore array index pointer */ - if (lval1->ident==iARRAYCELL || lval1->ident==iARRAYCHAR - || lval1->ident==iARRAY || lval1->ident==iREFARRAY) - { - /* if indirect fetch: save PRI (cell address) */ - if (oper) { - pushreg(sPRI); - rvalue(lval1); - } /* if */ - lval2.arrayidx=arrayidx2; - plnge2(oper,hier14,lval1,&lval2); - if (lval2.ident!=iARRAYCELL && lval2.ident!=iARRAYCHAR) - lval2.arrayidx=NULL; - if (oper) - popreg(sALT); - if (!oper && lval3.arrayidx!=NULL && lval2.arrayidx!=NULL - && lval3.ident==lval2.ident && lval3.sym==lval2.sym) - { - int same=TRUE; - assert(lval2.arrayidx==arrayidx2); - for (i=0; iname); /* self-assignment */ - } /* if */ - } else if (lval1->ident == iACCESSOR) { - pushreg(sPRI); - if (oper) { - rvalue(lval1); - plnge2(oper,hier14,lval1,&lval2); - } else { - if (hier14(&lval2)) - rvalue(&lval2); /* instead of plnge2(). */ - else if (lval2.ident==iVARIABLE) - lval2.ident=iEXPRESSION;/* mark as "rvalue" if it is not an "lvalue" */ - checkfunction(&lval2); - } - popreg(sALT); - } else { - if (oper){ - rvalue(lval1); - plnge2(oper,hier14,lval1,&lval2); - } else { - /* if direct fetch and simple assignment: no "push" - * and "pop" needed -> call hier14() directly, */ - if (hier14(&lval2)) - rvalue(&lval2); /* instead of plnge2(). */ - else if (lval2.ident==iVARIABLE) - lval2.ident=iEXPRESSION;/* mark as "rvalue" if it is not an "lvalue" */ - checkfunction(&lval2); - /* check whether lval2 and lval3 (old lval1) refer to the same variable */ - if (lval2.ident==iVARIABLE && lval3.ident==lval2.ident && lval3.sym==lval2.sym) { - assert(lval3.sym!=NULL); - error(226,lval3.sym->name); /* self-assignment */ - } /* if */ - } /* if */ - } /* if */ - /* Array elements are sometimes considered as sub-arrays --when the - * array index is an enumeration field and the enumeration size is greater - * than 1. If the expression on the right side of the assignment is a cell, - * or if an operation is in effect, this does not apply. - */ - leftarray= lval3.ident==iARRAY || lval3.ident==iREFARRAY - || ((lval3.ident==iARRAYCELL || lval3.ident==iARRAYCHAR) - && lval3.constval>1 && lval3.sym->dim.array.level==0 - && !oper && (lval2.ident==iARRAY || lval2.ident==iREFARRAY)); - if (leftarray) { - /* Left operand is an array, right operand should be an array variable - * of the same size and the same dimension, an array literal (of the - * same size) or a literal string. For single-dimensional arrays without - * tag for the index, it is permitted to assign a smaller array into a - * larger one (without warning). This is to make it easier to work with - * strings. - */ - int exactmatch=TRUE; - int idxtag=0; - int ltlength=(int)lval3.sym->dim.array.length; - if ((lval3.ident==iARRAYCELL || lval3.ident==iARRAYCHAR) - && lval3.constval>0 && lval3.sym->dim.array.level==0) - { - ltlength=(int)lval3.constval; - } /* if */ - if (lval2.ident!=iARRAY && lval2.ident!=iREFARRAY - && (lval2.sym==NULL || lval2.constval<=0)) - error(33,lval3.sym->name); /* array must be indexed */ - if (lval2.sym!=NULL) { - if (lval2.constval==0) { - val=lval2.sym->dim.array.length;/* array variable */ - } else { - val=lval2.constval; - if (lval2.sym->dim.array.level!=0) - error(28,lval2.sym->name); - } /* if */ - level=lval2.sym->dim.array.level; - idxtag=lval2.sym->x.tags.index; - if (level==0 && idxtag==0 && lval3.sym->x.tags.index==0) - exactmatch=FALSE; - } else { - val=lval2.constval; /* literal array */ - level=0; - /* If val is negative, it means that lval2 is a literal string. - * The string array size may be smaller than the destination - * array, provided that the destination array does not have an - * index tag. - */ - if (val<0) { - val=-val; - if (lval3.sym->x.tags.index==0) - exactmatch=FALSE; - } /* if */ - } /* if */ - if (lval3.sym->dim.array.level!=level) - return error(47); /* array dimensions must match */ - else if (ltlengthval) || val==0) - return error(47); /* array sizes must match */ - else if (lval3.ident!=iARRAYCELL && !matchtag(lval3.sym->x.tags.index,idxtag,MATCHTAG_COERCE|MATCHTAG_SILENT)) - error(229,(lval2.sym!=NULL) ? lval2.sym->name : lval3.sym->name); /* index tag mismatch */ - if (level>0) { - /* check the sizes of all sublevels too */ - symbol *sym1 = lval3.sym; - symbol *sym2 = lval2.sym; - int i; - error(23); - assert(sym1!=NULL && sym2!=NULL); - /* ^^^ sym2 must be valid, because only variables can be - * multi-dimensional (there are no multi-dimensional literals), - * sym1 must be valid because it must be an lvalue - */ - assert(exactmatch); - for (i=0; idim.array.length!=sym2->dim.array.length) - error(47); /* array sizes must match */ - else if (!matchtag(sym1->x.tags.index,sym2->x.tags.index,MATCHTAG_COERCE|MATCHTAG_SILENT)) - error(229,sym2->name); /* index tag mismatch */ - } /* for */ - /* get the total size in cells of the multi-dimensional array */ - val=array_totalsize(lval3.sym); - assert(val>0); /* already checked */ - } /* if */ - } else { - /* left operand is not an array, right operand should then not be either */ - if (lval2.ident==iARRAY || lval2.ident==iREFARRAY) - error(6); /* must be assigned to an array */ - } /* if */ - if (leftarray) { - memcopy(val*sizeof(cell)); - } else { - check_userop(NULL,lval2.tag,lval3.tag,2,&lval3,&lval2.tag); - store(&lval3); /* now, store the expression result */ - } /* if */ - if (!oper && !checktag_string(&lval3, &lval2)) { - if ((lval3.tag == pc_tag_string && lval2.tag != pc_tag_string) || - (lval3.tag != pc_tag_string && lval2.tag == pc_tag_string)) - { - error(179, type_to_name(lval3.tag), type_to_name(lval2.tag)); - } else { - matchtag(lval3.tag,lval2.tag,TRUE); - } - } - if (lval3.sym) - markusage(lval3.sym,uWRITTEN); - sideeffect=TRUE; - bitwise_opercount=bwcount; - lval1->ident=iEXPRESSION; - return FALSE; /* expression result is never an lvalue */ -} - -/** - * Sums up array usage in the current heap tracer and convert it into a dynamic array. - * This is used for the ternary operator, which needs to convert its array usage into - * something dynamically managed. - * !Note: - * This might break if expressions can ever return dynamic arrays. - * Thus, we assert() if something is non-static here. - * Right now, this poses no problem because this type of expression is impossible: - * (a() ? return_array() : return_array()) ? return_array() : return_array() - */ - -long dynarray_from_heaplist(memuse_list_t *heap) -{ - memuse_t *use=heap->head; - memuse_t *tmp; - long total=0; - while (use) { - assert(use->type==MEMUSE_STATIC); - total+=use->size; - tmp=use->prev; - free(use); - use=tmp; - } - free(heap); - if (total) - setheap_save(-total*sizeof(cell)); - return total; -} - -static int hier13(value *lval) -{ - int lvalue=plnge1(hier12,lval); - if (matchtoken('?')) { - int flab1=getlabel(); - int flab2=getlabel(); - value lval2={0}; - int array1,array2; - long total1,total2; - memuse_list_t *heap; - - pushheaplist(); - if (lvalue) { - rvalue(lval); - } else if (lval->ident==iCONSTEXPR) { - ldconst(lval->constval,sPRI); - error(lval->constval ? 206 : 205); /* redundant test */ - } /* if */ - jmp_eq0(flab1); /* go to second expression if primary register==0 */ - PUSHSTK_I(sc_allowtags); - sc_allowtags=FALSE; /* do not allow tagnames here (colon is a special token) */ - if (hier13(lval)) - rvalue(lval); - if (lval->ident==iCONSTEXPR) /* load constant here */ - ldconst(lval->constval,sPRI); - sc_allowtags=(short)POPSTK_I(); /* restore */ - heap=popsaveheaplist(); - total1=dynarray_from_heaplist(heap); - pushheaplist(); - jumplabel(flab2); - setlabel(flab1); - needtoken(':'); - if (hier13(&lval2)) - rvalue(&lval2); - if (lval2.ident==iCONSTEXPR) /* load constant here */ - ldconst(lval2.constval,sPRI); - array1= (lval->ident==iARRAY || lval->ident==iREFARRAY); - array2= (lval2.ident==iARRAY || lval2.ident==iREFARRAY); - if (!array1 && array2) { - const char *ptr = "-unknown-"; - if (lval->sym != NULL) - ptr = lval->sym->name; - error(33,ptr); /* array must be indexed */ - } else if (array1 && !array2) { - const char *ptr = "-unknown-"; - if (lval2.sym != NULL) - ptr = lval2.sym->name; - error(33,ptr); /* array must be indexed */ - } /* if */ - /* ??? if both are arrays, should check dimensions */ - matchtag(lval->tag,lval2.tag,FALSE); - heap=popsaveheaplist(); - total2=dynarray_from_heaplist(heap); - setlabel(flab2); - if ((array1 && array2) && (total1 && total2)) { - markheap(MEMUSE_DYNAMIC, 0); - } - /* If both sides are arrays, we should return the maximal as the lvalue. - * Otherwise we could buffer overflow and the compiler is too stupid. - * Literal strings have a constval == -(num_cells) so the cmp is flipped. - */ - if (lval->ident==iARRAY && lval2.ident==iARRAY - && lval->constval < 0 - && lval->constval > lval2.constval) { - *lval = lval2; - } - if (lval->ident==iARRAY) - lval->ident=iREFARRAY; /* iARRAY becomes iREFARRAY */ - else if (lval->ident!=iREFARRAY) - lval->ident=iEXPRESSION; /* iREFARRAY stays iREFARRAY, rest becomes iEXPRESSION */ - return FALSE; /* conditional expression is no lvalue */ - } else { - return lvalue; - } /* if */ -} - -/* the order of the operators in these lists is important and must be - * the same as the order of the operators in the array "op1" - */ -static int list3[] = {'*','/','%',0}; -static int list4[] = {'+','-',0}; -static int list5[] = {tSHL,tSHR,tSHRU,0}; -static int list6[] = {'&',0}; -static int list7[] = {'^',0}; -static int list8[] = {'|',0}; -static int list9[] = {tlLE,tlGE,'<','>',0}; -static int list10[] = {tlEQ,tlNE,0}; -static int list11[] = {tlAND,0}; -static int list12[] = {tlOR,0}; - -static int hier12(value *lval) -{ - return skim(list12,jmp_ne0,1,0,hier11,lval); -} - -static int hier11(value *lval) -{ - return skim(list11,jmp_eq0,0,1,hier10,lval); -} - -static int hier10(value *lval) -{ /* ==, != */ - return plnge(list10,15,hier9,lval,"bool",TRUE); -} /* ^ this variable is the starting index in the op1[] - * array of the operators of this hierarchy level */ - -static int hier9(value *lval) -{ /* <=, >=, <, > */ - return plnge_rel(list9,11,hier8,lval); -} - -static int hier8(value *lval) -{ /* | */ - return plnge(list8,10,hier7,lval,NULL,FALSE); -} - -static int hier7(value *lval) -{ /* ^ */ - return plnge(list7,9,hier6,lval,NULL,FALSE); -} - -static int hier6(value *lval) -{ /* & */ - return plnge(list6,8,hier5,lval,NULL,FALSE); -} - -static int hier5(value *lval) -{ /* <<, >>, >>> */ - return plnge(list5,5,hier4,lval,NULL,FALSE); -} - -static int hier4(value *lval) -{ /* +, - */ - return plnge(list4,3,hier3,lval,NULL,FALSE); -} - -static int hier3(value *lval) -{ /* *, /, % */ - return plnge(list3,0,hier2,lval,NULL,FALSE); -} - -static int hier2(value *lval) -{ - int lvalue,tok; - int tag,paranthese; - cell val; - char *st; - symbol *sym; - int saveresult; - - tok=lex(&val,&st); - switch (tok) { - case tINC: /* ++lval */ - if (!hier2(lval)) - return error(22); /* must be lvalue */ - if (lval->ident != iACCESSOR) { - assert(lval->sym!=NULL); - if ((lval->sym->usage & uCONST)!=0) - return error(22); /* assignment to const argument */ - if (!check_userop(user_inc,lval->tag,0,1,lval,&lval->tag)) - inc(lval); /* increase variable first */ - rvalue(lval); /* and read the result into PRI */ - } else { - pushreg(sPRI); - invoke_getter(lval->accessor); - if (!check_userop(user_inc,lval->tag,0,1,lval,&lval->tag)) - inc_pri(); - popreg(sALT); - invoke_setter(lval->accessor, TRUE); - lval->ident = iEXPRESSION; - } - sideeffect=TRUE; - return FALSE; /* result is no longer lvalue */ - case tDEC: /* --lval */ - if (!hier2(lval)) - return error(22); /* must be lvalue */ - if (lval->ident != iACCESSOR) { - assert(lval->sym!=NULL); - if ((lval->sym->usage & uCONST)!=0) - return error(22); /* assignment to const argument */ - if (!check_userop(user_dec,lval->tag,0,1,lval,&lval->tag)) - dec(lval); /* decrease variable first */ - rvalue(lval); /* and read the result into PRI */ - } else { - pushreg(sPRI); - invoke_getter(lval->accessor); - if (!check_userop(user_dec,lval->tag,0,1,lval,&lval->tag)) - dec_pri(); - popreg(sALT); - invoke_setter(lval->accessor, TRUE); - lval->ident = iEXPRESSION; - } - sideeffect=TRUE; - return FALSE; /* result is no longer lvalue */ - case '~': /* ~ (one's complement) */ - if (hier2(lval)) - rvalue(lval); - invert(); /* bitwise NOT */ - lval->constval=~lval->constval; - return FALSE; - case '!': /* ! (logical negate) */ - if (hier2(lval)) - rvalue(lval); - if (check_userop(lneg,lval->tag,0,1,NULL,&lval->tag)) { - lval->ident=iEXPRESSION; - lval->constval=0; - } else { - lneg(); /* 0 -> 1, !0 -> 0 */ - lval->constval=!lval->constval; - lval->tag=pc_addtag("bool"); - } /* if */ - return FALSE; - case '-': /* unary - (two's complement) */ - if (hier2(lval)) - rvalue(lval); - /* make a special check for a constant expression with the tag of a - * rational number, so that we can simple swap the sign of that constant. - */ - if (lval->ident==iCONSTEXPR && lval->tag==sc_rationaltag && sc_rationaltag!=0) { - if (rational_digits==0) { - #if PAWN_CELL_SIZE==32 - float *f = (float *)&lval->constval; - #elif PAWN_CELL_SIZE==64 - double *f = (double *)&lval->constval; - #else - #error Unsupported cell size - #endif - *f= - *f; /* this modifies lval->constval */ - } else { - /* the negation of a fixed point number is just an integer negation */ - lval->constval=-lval->constval; - } /* if */ - } else if (check_userop(neg,lval->tag,0,1,NULL,&lval->tag)) { - lval->ident=iEXPRESSION; - lval->constval=0; - } else { - neg(); /* arithmic negation */ - lval->constval=-lval->constval; - } /* if */ - return FALSE; - case tNEW: /* call nullable methodmap constructor */ - { - tok = lex(&val, &st); - if (tok != tSYMBOL) - return error(20, st); /* illegal symbol name */ - - symbol *target = NULL; - methodmap_t *methodmap = methodmap_find_by_name(st); - if (!methodmap) - error(116, st); - else if (!methodmap->nullable) - error(171, methodmap->name); - else if (!methodmap->ctor) - error(172, methodmap->name); - else - target = methodmap->ctor->target; - - if (!target) { - needtoken('('); - int depth = 1; - // Eat tokens until we get a newline or EOF or ')' or ';' - while (true) { - if (peek_same_line() == tEOL) - return FALSE; - if ((tok = lex(&val, &st)) == 0) - return FALSE; - if (tok == ')') { - if (--depth == 0) - return FALSE; - } - if (tok == ';') - return FALSE; - if (tok == '(') - depth++; - } - } - - needtoken('('); - callfunction(target, NULL, lval, TRUE); - return FALSE; - } - case tVIEW_AS: /* newer tagname override */ - { - needtoken('<'); - int tag = 0; - { - token_t tok; - lextok(&tok); - if (!parse_new_typename(&tok, &tag)) - tag = 0; - } - needtoken('>'); - - if (tag == pc_tag_void) - error(144); - - lval->cmptag = tag; - lvalue = hier12(lval); - - if ((lval->tag & OBJECTTAG) || (tag & OBJECTTAG)) { - matchtag(tag, lval->tag, MATCHTAG_COERCE); - } else if ((tag & FUNCTAG) != (lval->tag & FUNCTAG)) { - // Warn: unsupported cast. - error(237); - } - lval->tag = tag; - return lvalue; - } - case tLABEL: /* tagname override */ - tag=pc_addtag(st); - if (sc_require_newdecls) { - // Warn: old style cast used when newdecls pragma is enabled - error(240, st, type_to_name(tag)); - } - lval->cmptag=tag; - lvalue=hier2(lval); - if ((lval->tag & OBJECTTAG) || (tag & OBJECTTAG)) { - matchtag(tag, lval->tag, MATCHTAG_COERCE); - } else if ((tag & FUNCTAG) != (lval->tag & FUNCTAG)) { - // Warn: unsupported cast. - error(237); - } - lval->tag=tag; - return lvalue; - case tDEFINED: - paranthese=0; - while (matchtoken('(')) - paranthese++; - tok=lex(&val,&st); - if (tok!=tSYMBOL) - return error(20,st); /* illegal symbol name */ - sym=findloc(st); - if (sym==NULL) - sym=findglb(st,sSTATEVAR); - if (sym!=NULL && sym->ident!=iFUNCTN && sym->ident!=iREFFUNC && (sym->usage & uDEFINE)==0) - sym=NULL; /* symbol is not a function, it is in the table, but not "defined" */ - val= (sym!=NULL); - if (!val && find_subst(st,strlen(st))!=NULL) - val=1; - clear_value(lval); - lval->ident=iCONSTEXPR; - lval->constval= val; - lval->tag=pc_addtag("bool"); - ldconst(lval->constval,sPRI); - while (paranthese--) - needtoken(')'); - return FALSE; - case tSIZEOF: - paranthese=0; - while (matchtoken('(')) - paranthese++; - tok=lex(&val,&st); - if (tok!=tSYMBOL) - return error(20,st); /* illegal symbol name */ - sym=findloc(st); - if (sym==NULL) - sym=findglb(st,sSTATEVAR); - if (sym==NULL) - return error(17,st); /* undefined symbol */ - if (sym->ident==iCONSTEXPR) - error(39); /* constant symbol has no size */ - else if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) - error(72); /* "function" symbol has no size */ - else if ((sym->usage & uDEFINE)==0) - return error(17,st); /* undefined symbol (symbol is in the table, but it is "used" only) */ - clear_value(lval); - lval->ident=iCONSTEXPR; - lval->constval=1; /* preset */ - markusage(sym, uREAD); - if (sym->ident==iARRAY || sym->ident==iREFARRAY) { - int level; - symbol *idxsym=NULL; - symbol *subsym=sym; - for (level=0; matchtoken('['); level++) { - idxsym=NULL; - if (subsym!=NULL && level==subsym->dim.array.level && matchtoken(tSYMBOL)) { - char *idxname; - int cmptag=subsym->x.tags.index; - tokeninfo(&val,&idxname); - if ((idxsym=findconst(idxname,&cmptag))==NULL) - error(80,idxname); /* unknown symbol, or non-constant */ - else if (cmptag>1) - error(91,idxname); /* ambiguous constant */ - } /* if */ - needtoken(']'); - if (subsym!=NULL) - subsym=finddepend(subsym); - } /* for */ - if (level>sym->dim.array.level+1) { - error(28,sym->name); /* invalid subscript */ - } else if (level==sym->dim.array.level+1) { - lval->constval=(idxsym!=NULL && idxsym->dim.array.length>0) ? idxsym->dim.array.length : 1; - } else { - lval->constval=array_levelsize(sym,level); - } - if (lval->constval==0 && strchr((char *)lptr,PREPROC_TERM)==NULL) - error(163,st); /* indeterminate array size in "sizeof" expression */ - } /* if */ - ldconst(lval->constval,sPRI); - while (paranthese--) - needtoken(')'); - return FALSE; - case tCELLSOF: - paranthese=0; - while (matchtoken('(')) - paranthese++; - tok=lex(&val,&st); - if (tok!=tSYMBOL) - return error(20,st); /* illegal symbol name */ - sym=findloc(st); - if (sym==NULL) - sym=findglb(st,sSTATEVAR); - if (sym==NULL) - return error(17,st); /* undefined symbol */ - if (sym->ident==iCONSTEXPR) - error(39); /* constant symbol has no size */ - else if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) - error(72); /* "function" symbol has no size */ - else if ((sym->usage & uDEFINE)==0) - return error(17,st); /* undefined symbol (symbol is in the table, but it is "used" only) */ - clear_value(lval); - lval->ident=iCONSTEXPR; - lval->constval=1; /* preset */ - if (sym->ident==iARRAY || sym->ident==iREFARRAY) { - int level; - symbol *idxsym=NULL; - symbol *subsym=sym; - for (level=0; matchtoken('['); level++) { - idxsym=NULL; - if (subsym!=NULL && level==subsym->dim.array.level && matchtoken(tSYMBOL)) { - char *idxname; - int cmptag=subsym->x.tags.index; - tokeninfo(&val,&idxname); - if ((idxsym=findconst(idxname,&cmptag))==NULL) - error(80,idxname); /* unknown symbol, or non-constant */ - else if (cmptag>1) - error(91,idxname); /* ambiguous constant */ - } /* if */ - needtoken(']'); - if (subsym!=NULL) - subsym=finddepend(subsym); - } /* for */ - if (level>sym->dim.array.level+1) { - error(28,sym->name); /* invalid subscript */ - } else if (level==sym->dim.array.level+1) { - lval->constval= (idxsym!=NULL && idxsym->dim.array.length>0) ? idxsym->dim.array.length : 1; - } else { - lval->constval=array_levelsize(sym,level); - } - if (lval->constval==0 && strchr((char *)lptr,PREPROC_TERM)==NULL) - error(163,st); /* indeterminate array size in "sizeof" expression */ - } /* if */ - ldconst(lval->constval,sPRI); - while (paranthese--) - needtoken(')'); - return FALSE; - case tTAGOF: - paranthese=0; - while (matchtoken('(')) - paranthese++; - tok=lex(&val,&st); - if (tok!=tSYMBOL && tok!=tLABEL) - return error(20,st); /* illegal symbol name */ - if (tok==tLABEL) { - constvalue *tagsym=find_constval(&tagname_tab,st,0); - tag=(int)((tagsym!=NULL) ? tagsym->value : 0); - } else { - sym=findloc(st); - if (sym==NULL) - sym=findglb(st,sSTATEVAR); - if (sym==NULL) - return error(17,st); /* undefined symbol */ - if ((sym->usage & uDEFINE)==0) - return error(17,st); /* undefined symbol (symbol is in the table, but it is "used" only) */ - tag=sym->tag; - } /* if */ - if (sym->ident==iARRAY || sym->ident==iREFARRAY) { - int level; - symbol *idxsym=NULL; - symbol *subsym=sym; - for (level=0; matchtoken('['); level++) { - idxsym=NULL; - if (subsym!=NULL && level==subsym->dim.array.level && matchtoken(tSYMBOL)) { - char *idxname; - int cmptag=subsym->x.tags.index; - tokeninfo(&val,&idxname); - if ((idxsym=findconst(idxname,&cmptag))==NULL) - error(80,idxname); /* unknown symbol, or non-constant */ - else if (cmptag>1) - error(91,idxname); /* ambiguous constant */ - } /* if */ - needtoken(']'); - if (subsym!=NULL) - subsym=finddepend(subsym); - } /* for */ - if (level>sym->dim.array.level+1) - error(28,sym->name); /* invalid subscript */ - else if (level==sym->dim.array.level+1 && idxsym!=NULL) - tag= idxsym->x.tags.index; - } /* if */ - clear_value(lval); - lval->ident=iCONSTEXPR; - lval->constval=tag; - ldconst(lval->constval,sPRI); - while (paranthese--) - needtoken(')'); - return FALSE; - default: - lexpush(); - lvalue=hier1(lval); - /* check for postfix operators */ - if (matchtoken(';')) { - /* Found a ';', do not look further for postfix operators */ - lexpush(); /* push ';' back after successful match */ - return lvalue; - } else if (matchtoken(tTERM)) { - /* Found a newline that ends a statement (this is the case when - * semicolons are optional). Note that an explicit semicolon was - * handled above. This case is similar, except that the token must - * not be pushed back. - */ - return lvalue; - } else { - tok=lex(&val,&st); - switch (tok) { - case tINC: /* lval++ */ - if (!lvalue) - return error(22); /* must be lvalue */ - if (lval->ident != iACCESSOR) { - assert(lval->sym!=NULL); - if ((lval->sym->usage & uCONST)!=0) - return error(22); /* assignment to const argument */ - /* on incrementing array cells, the address in PRI must be saved for - * incremening the value, whereas the current value must be in PRI - * on exit. - */ - saveresult= (lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR); - if (saveresult) - pushreg(sPRI); /* save address in PRI */ - rvalue(lval); /* read current value into PRI */ - if (saveresult) - swap1(); /* save PRI on the stack, restore address in PRI */ - if (!check_userop(user_inc,lval->tag,0,1,lval,&lval->tag)) - inc(lval); /* increase variable afterwards */ - if (saveresult) - popreg(sPRI); /* restore PRI (result of rvalue()) */ - } else { - pushreg(sPRI); // save obj - invoke_getter(lval->accessor); - move_alt(); // alt = oldval - swap1(); // pri = saved obj, stack = [oldval] - pushreg(sPRI); // pri = obj, alt = oldval, stack = [obj, oldval] - moveto1(); // pri = oldval, stack = [obj, oldval] - - // check_userop on an iACCESSOR acts as though the value is an rvalue. - if (!check_userop(user_inc, lval->tag, 0, 1, lval, &lval->tag)) - inc_pri(); - - popreg(sALT); - invoke_setter(lval->accessor, FALSE); - popreg(sPRI); - lval->ident = iEXPRESSION; - } - sideeffect=TRUE; - return FALSE; /* result is no longer lvalue */ - case tDEC: /* lval-- */ - if (!lvalue) - return error(22); /* must be lvalue */ - if (lval->ident != iACCESSOR) { - assert(lval->sym!=NULL); - if ((lval->sym->usage & uCONST)!=0) - return error(22); /* assignment to const argument */ - saveresult= (lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR); - if (saveresult) - pushreg(sPRI); /* save address in PRI */ - rvalue(lval); /* read current value into PRI */ - if (saveresult) - swap1(); /* save PRI on the stack, restore address in PRI */ - if (!check_userop(user_dec,lval->tag,0,1,lval,&lval->tag)) - dec(lval); /* decrease variable afterwards */ - if (saveresult) - popreg(sPRI); /* restore PRI (result of rvalue()) */ - } else { - pushreg(sPRI); // save obj - invoke_getter(lval->accessor); - move_alt(); // alt = oldval - swap1(); // pri = saved obj, stack = [oldval] - pushreg(sPRI); // pri = obj, alt = oldval, stack = [obj, oldval] - moveto1(); // pri = oldval, stack = [obj, oldval] - - // check_userop on an iACCESSOR acts as though the value is an rvalue. - if (!check_userop(user_dec, lval->tag, 0, 1, lval, &lval->tag)) - dec_pri(); - - popreg(sALT); - invoke_setter(lval->accessor, FALSE); - popreg(sPRI); - lval->ident = iEXPRESSION; - } - sideeffect=TRUE; - return FALSE; -/* This is temporarily disabled because we detect it automatically. - * Thus, it could be weird if both were used at once - */ -#if 0 - case tCHAR: /* char (compute required # of cells */ - if (lval->ident==iCONSTEXPR) { - lval->constval *= sCHARBITS/8; /* from char to bytes */ - lval->constval = (lval->constval + sizeof(cell)-1) / sizeof(cell); - } else { - if (lvalue) - rvalue(lval); /* fetch value if not already in PRI */ - char2addr(); /* from characters to bytes */ - addconst(sizeof(cell)-1); /* make sure the value is rounded up */ - addr2cell(); /* truncate to number of cells */ - } /* if */ - return FALSE; -#endif - default: - lexpush(); - return lvalue; - } /* switch */ - } /* if */ - } /* switch */ -} - -static symbol * -fake_function_for_method(methodmap_t *map, const char *lexstr) -{ - // Fetch a fake function so errors aren't as crazy. - char tmpname[METHOD_NAMEMAX + 1]; - strcpy(tmpname, map->name); - strcat(tmpname, "."); - strcat(tmpname, lexstr); - tmpname[sNAMEMAX] = '\0'; - return fetchfunc(tmpname); -} - -enum FieldExprResult -{ - FER_Fail, - FER_Accessor, - FER_CallFunction, - FER_CallMethod -}; - -static FieldExprResult -field_expression(svalue &thisval, value *lval, symbol **target) -{ - // Catch invalid calls early so we don't compile with a tag mismatch. - switch (thisval.val.ident) { - case iARRAY: - case iREFARRAY: - error(106); - break; - - case iFUNCTN: - case iREFFUNC: - error(107); - break; - } - - cell lexval; - char *lexstr; - if (!needtoken(tSYMBOL)) - return FER_Fail; - tokeninfo(&lexval, &lexstr); - - if (thisval.val.ident == iMETHODMAP) { - methodmap_t *map = thisval.val.sym->methodmap; - methodmap_method_t *method = methodmap_find_method(map, lexstr); - if (!method) { - error(105, map->name, lexstr); - *target = fake_function_for_method(map, lexstr); - return FER_CallFunction; - } - - if (!method->is_static) - error(176, method->name, map->name); - *target = method->target; - return FER_CallFunction; - } - - methodmap_t *map; - if ((map = methodmap_find_by_tag(thisval.val.tag)) == NULL) { - error(104, pc_tagname(thisval.val.tag)); - return FER_Fail; - } - - methodmap_method_t *method; - if ((method = methodmap_find_method(map, lexstr)) == NULL) { - error(105, map->name, lexstr); - *target = fake_function_for_method(map, lexstr); - return FER_CallFunction; - } - - if (method && (method->getter || method->setter)) { - if (thisval.lvalue) - rvalue(lval); - clear_value(lval); - lval->ident = iACCESSOR; - lval->tag = method->property_tag(); - lval->accessor = method; - return FER_Accessor; - } - - *target = method->target; - - if (method->is_static) { - error(177, method->name, map->name, method->name); - return FER_CallFunction; - } - return FER_CallMethod; -} - - -/* hier1 - * - * The highest hierarchy level: it looks for pointer and array indices - * and function calls. - * Generates code to fetch a pointer value if it is indexed and code to - * add to the pointer value or the array address (the address is already - * read at primary()). It also generates code to fetch a function address - * if that hasn't already been done at primary() (check lval[4]) and calls - * callfunction() to call the function. - */ -static int hier1(value *lval1) -{ - int lvalue,index,tok,symtok; - cell val,cidx; - value lval2={0}; - char *st; - char close; - symbol *sym; - int magic_string=0; - symbol dummysymbol,*cursym; /* for changing the index tags in case of enumerated pseudo-arrays */ - - lvalue=primary(lval1); - symtok=tokeninfo(&val,&st); /* get token read by primary() */ - cursym=lval1->sym; - -restart: - sym=cursym; - - if (lval1->ident == iMETHODMAP && - !(lexpeek('.') || lexpeek('('))) - { - // Cannot use methodmap as an rvalue/lvalue. - error(174, sym ? sym->name : "(unknown)"); - - lval1->ident = iCONSTEXPR; - lval1->tag = 0; - lval1->constval = 0; - } - - if (matchtoken('[') || matchtoken('{') || matchtoken('(') || matchtoken('.')) { - tok=tokeninfo(&val,&st); /* get token read by matchtoken() */ - if (lvalue && lval1->ident == iACCESSOR) { - rvalue(lval1); - lvalue = FALSE; - } - magic_string = (sym && (sym->tag == pc_tag_string && sym->dim.array.level == 0)); - if (sym==NULL && symtok!=tSYMBOL) { - /* we do not have a valid symbol and we appear not to have read a valid - * symbol name (so it is unlikely that we would have read a name of an - * undefined symbol) */ - error(29); /* expression error, assumed 0 */ - lexpush(); /* analyse '(', '{' or '[' again later */ - return FALSE; - } /* if */ - if (tok=='[' || tok=='{') { /* subscript */ - close = (char)((tok=='[') ? ']' : '}'); - if (sym==NULL) { /* sym==NULL if lval is a constant or a literal */ - error(28,""); /* cannot subscript */ - needtoken(close); - return FALSE; - } else if (sym->ident!=iARRAY && sym->ident!=iREFARRAY){ - error(28,sym->name); /* cannot subscript, variable is not an array */ - needtoken(close); - return FALSE; - } else if (sym->dim.array.level>0 && close!=']') { - error(51); /* invalid subscript, must use [ ] */ - needtoken(close); - return FALSE; - } /* if */ - /* set the tag to match (enumeration fields as indices) */ - lval2.cmptag=sym->x.tags.index; - stgget(&index,&cidx); /* mark position in code generator */ - pushreg(sPRI); /* save base address of the array */ - if (hier14(&lval2)) /* create expression for the array index */ - rvalue(&lval2); - if (lval2.ident==iARRAY || lval2.ident==iREFARRAY) - error(33,lval2.sym->name); /* array must be indexed */ - needtoken(close); - if ((sym->usage & uENUMROOT)) - matchtag(sym->x.tags.index,lval2.tag,TRUE); - if (lval2.ident==iCONSTEXPR) { /* constant expression */ - stgdel(index,cidx); /* scratch generated code */ - if (lval1->arrayidx!=NULL) { /* keep constant index, for checking */ - assert(sym->dim.array.level>=0 && sym->dim.array.levelarrayidx[sym->dim.array.level]=lval2.constval; - } /* if */ - if (close==']' && !(sym->tag == pc_tag_string && sym->dim.array.level == 0)) { - /* normal array index */ - if (lval2.constval<0 || (sym->dim.array.length!=0 && sym->dim.array.length<=lval2.constval)) - error(32,sym->name); /* array index out of bounds */ - if (lval2.constval!=0) { - /* don't add offsets for zero subscripts */ - #if PAWN_CELL_SIZE==16 - ldconst(lval2.constval<<1,sALT); - #elif PAWN_CELL_SIZE==32 - ldconst(lval2.constval<<2,sALT); - #elif PAWN_CELL_SIZE==64 - ldconst(lval2.constval<<3,sALT); - #else - #error Unsupported cell size - #endif - ob_add(); - } /* if */ - } else { - /* character index */ - if (lval2.constval<0 || (sym->dim.array.length!=0 - && sym->dim.array.length*((8*sizeof(cell))/sCHARBITS)<=(ucell)lval2.constval)) - error(32,sym->name); /* array index out of bounds */ - if (lval2.constval!=0) { - /* don't add offsets for zero subscripts */ - #if sCHARBITS==16 - ldconst(lval2.constval<<1,sALT);/* 16-bit character */ - #else - ldconst(lval2.constval,sALT); /* 8-bit character */ - #endif - ob_add(); - } /* if */ - charalign(); /* align character index into array */ - } /* if */ - /* if the array index is a field from an enumeration, get the tag name - * from the field and save the size of the field too. - */ - assert(lval2.sym==NULL || lval2.sym->dim.array.level==0); - if (lval2.sym!=NULL && lval2.sym->dim.array.length>0 && sym->dim.array.level==0) { - lval1->tag=lval2.sym->x.tags.index; - lval1->constval=lval2.sym->dim.array.length; - } /* if */ - } else { - /* array index is not constant */ - lval1->arrayidx=NULL; /* reset, so won't be checked */ - if (close==']' && !magic_string) { - if (sym->dim.array.length!=0) - ffbounds(sym->dim.array.length-1); /* run time check for array bounds */ - cell2addr(); /* normal array index */ - } else { - if (sym->dim.array.length!=0) - ffbounds(sym->dim.array.length*(32/sCHARBITS)-1); - char2addr(); /* character array index */ - } /* if */ - popreg(sALT); - ob_add(); /* base address was popped into secondary register */ - if (close!=']' || magic_string) - charalign(); /* align character index into array */ - } /* if */ - /* the indexed item may be another array (multi-dimensional arrays) */ - assert(cursym==sym && sym!=NULL); /* should still be set */ - if (sym->dim.array.level>0) { - assert(close==']'); /* checked earlier */ - assert(cursym==lval1->sym); - /* read the offset to the subarray and add it to the current address */ - lval1->ident=iARRAYCELL; - pushreg(sPRI); /* the optimizer makes this to a MOVE.alt */ - rvalue(lval1); - popreg(sALT); - ob_add(); - /* adjust the "value" structure and find the referenced array */ - lval1->ident=iREFARRAY; - lval1->sym=finddepend(sym); - assert(lval1->sym!=NULL); - assert(lval1->sym->dim.array.level==sym->dim.array.level-1); - cursym=lval1->sym; - /* try to parse subsequent array indices */ - lvalue=FALSE; /* for now, a iREFARRAY is no lvalue */ - goto restart; - } /* if */ - assert(sym->dim.array.level==0); - /* set type to fetch... INDIRECTLY */ - if (sym->tag == pc_tag_string) { - lval1->ident = iARRAYCHAR; - } else { - lval1->ident= (char)((close==']') ? iARRAYCELL : iARRAYCHAR); - } - /* if the array index is a field from an enumeration, get the tag name - * from the field and save the size of the field too. Otherwise, the - * tag is the one from the array symbol. - */ - if (lval2.ident==iCONSTEXPR && lval2.sym!=NULL - && lval2.sym->dim.array.length>0 && sym->dim.array.level==0) - { - lval1->tag=lval2.sym->x.tags.index; - lval1->constval=lval2.sym->dim.array.length; - if (lval2.tag==sym->x.tags.index && lval1->constval>1 && matchtoken('[')) { - /* an array indexed with an enumeration field may be considered a sub-array */ - lexpush(); - lvalue=FALSE; /* for now, a iREFARRAY is no lvalue */ - lval1->ident=iREFARRAY; - /* initialize a dummy symbol, which is a copy of the current symbol, - * but with an adjusted index tag - */ - assert(sym!=NULL); - dummysymbol=*sym; - /* get the tag of the root of the enumeration */ - assert(lval2.sym!=NULL); - dummysymbol.x.tags.index=lval2.sym->x.tags.field; - dummysymbol.dim.array.length=lval2.sym->dim.array.length; - cursym=&dummysymbol; - /* recurse */ - goto restart; - } /* if */ - } else { - assert(sym!=NULL); - if (cursym!=&dummysymbol) - lval1->tag=sym->tag; - lval1->constval=0; - } /* if */ - - // If there's a call/fetch coming up, keep parsing. - if (matchtoken('.')) { - lexpush(); - goto restart; - } - - /* a cell in an array is an lvalue, a character in an array is not - * always a *valid* lvalue */ - return TRUE; - } else { /* tok=='(' -> function(...) */ - svalue thisval; - thisval.val = *lval1; - thisval.lvalue = lvalue; - - svalue *implicitthis = NULL; - if (tok == '.') { - switch (field_expression(thisval, lval1, &sym)) { - case FER_Fail: - case FER_CallFunction: - break; - case FER_CallMethod: - implicitthis = &thisval; - break; - case FER_Accessor: - goto restart; - default: - assert(false); - } - - // If we don't find a '(' next, just fail to compile for now -- and - // don't even try to do a function call, just restart the parse loop. - if (!needtoken('(')) - goto restart; - - tok = '('; - } - - assert(tok=='('); - if (sym==NULL || (sym->ident!=iFUNCTN && sym->ident!=iREFFUNC)) { - if (sym && sym->ident == iMETHODMAP && sym->methodmap) { - if (!sym->methodmap->ctor) { - // Immediately fatal - no function to call. - return error(172, sym->name); - } - if (sym->methodmap->nullable) { - // Keep going, this is basically a style thing. - error(170, sym->methodmap->name); - } - - sym = sym->methodmap->ctor->target; - } else if (sym==NULL && sc_status==statFIRST) { - /* could be a "use before declaration"; in that case, create a stub - * function so that the usage can be marked. - */ - sym=fetchfunc(lastsymbol); - if (sym==NULL) - error(FATAL_ERROR_OOM); - markusage(sym,uREAD); - } else { - return error(12); /* invalid function call */ - } - } else if ((sym->usage & uMISSING)!=0) { - char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ - funcdisplayname(symname,sym->name); - error(4,symname); /* function not defined */ - } /* if */ - - callfunction(sym,implicitthis,lval1,TRUE); - if (lexpeek('.')) { - lvalue = FALSE; - goto restart; - } - return FALSE; /* result of function call is no lvalue */ - } /* if */ - } /* if */ - if (sym!=NULL && lval1->ident==iFUNCTN) { - assert(sym->ident==iFUNCTN); - - if (sym->usage & uNATIVE) { - error(76); - return FALSE; - } - - int public_index = 0; - symbol *target = NULL; - for (symbol *iter = glbtab.next; iter; iter = iter->next) { - if (iter->ident != iFUNCTN || iter->vclass != sGLOBAL) - continue; - if (strcmp(iter->name, lval1->sym->name) == 0) { - target = iter; - break; - } - if (iter->usage & uPUBLIC) - public_index++; - } - - if (!target || !(target->usage & uPUBLIC)) { - error(76); - return FALSE; - } - - funcenum_t *fe = funcenum_for_symbol(target); - lval1->sym = NULL; - lval1->ident = iCONSTEXPR; - lval1->constval = (public_index << 1) | 1; - lval1->tag = fe->tag; - target->usage |= uREAD; - } /* if */ - return lvalue; -} - -/* primary - * - * Returns 1 if the operand is an lvalue (everything except arrays, functions - * constants and -of course- errors). - * Generates code to fetch the address of arrays. Code for constants is - * already generated by constant(). - * This routine first clears the entire lval array (all fields are set to 0). - * - * Global references: sc_intest (may be altered, but restored upon termination) - */ -static int primary(value *lval) -{ - char *st; - int lvalue,tok; - cell val; - symbol *sym; - - if (matchtoken('(')){ /* sub-expression - (expression,...) */ - PUSHSTK_I(sc_intest); - PUSHSTK_I(sc_allowtags); - - sc_intest=FALSE; /* no longer in "test" expression */ - sc_allowtags=TRUE; /* allow tagnames to be used in parenthesized expressions */ - sc_allowproccall=FALSE; - do - lvalue=hier14(lval); - while (matchtoken(',')); - needtoken(')'); - lexclr(FALSE); /* clear lex() push-back, it should have been - * cleared already by needtoken() */ - sc_allowtags=(short)POPSTK_I(); - sc_intest=(short)POPSTK_I(); - return lvalue; - } /* if */ - - clear_value(lval); /* clear lval */ - tok=lex(&val,&st); - - if (tok == tTHIS) { - strcpy(lastsymbol, "this"); - if ((sym = findloc("this")) == NULL) { - error(166); /* 'this' outside method body */ - ldconst(0, sPRI); - return FALSE; - } - - assert(sym->ident == iVARIABLE); - lval->sym = sym; - lval->ident = sym->ident; - lval->tag = sym->tag; - return TRUE; - } - - if (tok==tSYMBOL) { - /* lastsymbol is char[sNAMEMAX+1], lex() should have truncated any symbol - * to sNAMEMAX significant characters */ - assert(strlen(st)ident==iLABEL) { - error(29); /* expression error, assumed 0 */ - ldconst(0,sPRI); /* load 0 */ - return FALSE; /* return 0 for labels (expression error) */ - } /* if */ - lval->sym=sym; - lval->ident=sym->ident; - lval->tag=sym->tag; - if (sym->ident==iARRAY || sym->ident==iREFARRAY) { - address(sym,sPRI); /* get starting address in primary register */ - return FALSE; /* return 0 for array (not lvalue) */ - } else { - return TRUE; /* return 1 if lvalue (not label or array) */ - } /* if */ - } /* if */ - /* now try a global variable */ - if ((sym = findglb(st, sSTATEVAR)) != 0) { - if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) { - /* if the function is only in the table because it was inserted as a - * stub in the first pass (i.e. it was "used" but never declared or - * implemented, issue an error - */ - if ((sym->usage & uPROTOTYPED)==0) - error(17,st); - } else { - if ((sym->usage & uDEFINE)==0) - error(17,st); - lval->sym=sym; - lval->ident=sym->ident; - lval->tag=sym->tag; - switch (sym->ident) { - case iARRAY: - case iREFARRAY: - address(sym,sPRI); /* get starting address in primary register */ - return FALSE; /* return 0 for array (not lvalue) */ - case iMETHODMAP: - return FALSE; - default: - return TRUE; /* return 1 if lvalue (not function or array) */ - } /* switch */ - } /* if */ - } else { - if (!sc_allowproccall) - return error(17,st); /* undefined symbol */ - /* an unknown symbol, but used in a way compatible with the "procedure - * call" syntax. So assume that the symbol refers to a function. - */ - assert(sc_status==statFIRST); - sym=fetchfunc(st); - if (sym==NULL) - error(FATAL_ERROR_OOM); - } /* if */ - assert(sym!=NULL); - assert(sym->ident==iFUNCTN || sym->ident==iREFFUNC); - lval->sym=sym; - lval->ident=sym->ident; - lval->tag=sym->tag; - return FALSE; /* return 0 for function (not an lvalue) */ - } /* if */ - lexpush(); /* push the token, it is analyzed by constant() */ - if (constant(lval)==0) { - error(29); /* expression error, assumed 0 */ - ldconst(0,sPRI); /* load 0 */ - } /* if */ - return FALSE; /* return 0 for constants (or errors) */ -} - -static void clear_value(value *lval) -{ - lval->sym=NULL; - lval->constval=0L; - lval->tag=0; - lval->ident=0; - lval->boolresult=FALSE; - lval->accessor=NULL; - /* do not clear lval->arrayidx, it is preset in hier14() */ - /* do not clear lval->cmptag */ -} - -static void setdefarray(cell *string,cell size,cell array_sz,cell *dataaddr,int fconst) -{ - /* The routine must copy the default array data onto the heap, as to avoid - * that a function can change the default value. An optimization is that - * the default array data is "dumped" into the data segment only once (on the - * first use). - */ - /* check whether to dump the default array */ - assert(dataaddr!=NULL); - if (sc_status==statWRITE && *dataaddr<0) { - int i; - *dataaddr=(litidx+glb_declared)*sizeof(cell); - for (i=0; i=size); - modheap((int)array_sz*sizeof(cell)); - markheap(MEMUSE_STATIC, array_sz); - /* ??? should perhaps fill with zeros first */ - memcopy(size*sizeof(cell)); - moveto1(); - } /* if */ -} - -static int findnamedarg(arginfo *arg,char *name) -{ - int i; - - for (i=0; arg[i].ident!=0 && arg[i].ident!=iVARARGS; i++) - if (strcmp(arg[i].name,name)==0) - return i; - return -1; -} - -int checktag(int tags[],int numtags,int exprtag) -{ - int i; - int errcount = errnum; - - if (numtags > 1 && (exprtag & OBJECTTAG)) { - // This would allow leaking of the pointer, unless we verify that all tags - // are object tags. It's easiest to just forbid this. The feature is broken - // anyway since there is no way to determine the actual value's type. - error(135); - return FALSE; - } - - assert(tags!=0); - assert(numtags>0); - for (i=0; iident=iEXPRESSION; /* preset, may be changed later */ - lval_result->constval=0; - lval_result->tag=sym->tag; - /* check whether this is a function that returns an array */ - symret=finddepend(sym); - assert(symret==NULL || symret->ident==iREFARRAY); - if (symret!=NULL) { - int retsize; - /* allocate space on the heap for the array, and pass the pointer to the - * reserved memory block as a hidden parameter - */ - retsize=(int)array_totalsize(symret); - assert(retsize>0); - modheap(retsize*sizeof(cell));/* address is in ALT */ - pushreg(sALT); /* pass ALT as the last (hidden) parameter */ - markheap(MEMUSE_STATIC, retsize); - /* also mark the ident of the result as "array" */ - lval_result->ident=iREFARRAY; - lval_result->sym=symret; - } /* if */ - pushheaplist(); - - nesting++; - assert(nest_stkusage>=0); - #if !defined NDEBUG - if (nesting==1) - assert(nest_stkusage==0); - #endif - sc_allowproccall=FALSE; /* parameters may not use procedure call syntax */ - - if ((sym->flags & flgDEPRECATED)!=0) { - const char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; - error(234,sym->name,ptr); /* deprecated (probably a native function) */ - } /* if */ - - /* run through the arguments */ - arg=sym->dim.arglist; - assert(arg!=NULL); - stgmark(sSTARTREORDER); - memset(arglist,ARG_UNHANDLED,sizeof arglist); - if (matchparanthesis) { - /* Opening brace was already parsed, if closing brace follows, this - * call passes no parameters. - */ - close=matchtoken(')'); - } else { - /* When we find an end of line here, it may be a function call passing - * no parameters, or it may be that the first parameter is on a line - * below. But as a parameter can be anything, this is difficult to check. - * The only simple check that we have is the use of "named parameters". - */ - close=matchtoken(tTERM); - if (close) { - close=!matchtoken('.'); - if (!close) - lexpush(); /* reset the '.' */ - } /* if */ - } /* if */ - if (pending_this || !close) { - do { - if (!pending_this && matchtoken('.')) { - namedparams=TRUE; - if (!needtoken(tSYMBOL)) - break; - tokeninfo(&lexval,&lexstr); - argpos=findnamedarg(arg,lexstr); - if (argpos<0) { - error(17,lexstr); /* undefined symbol */ - break; /* exit loop, argpos is invalid */ - } /* if */ - needtoken('='); - argidx=argpos; - } else { - if (namedparams) - error(44); /* positional parameters must precede named parameters */ - argpos=nargs; - } /* if */ - /* the number of arguments this was already checked at the declaration - * of the function; check it again for functions with a variable - * argument list - */ - if (argpos>=sMAXARGS) - error(45); /* too many function arguments */ - stgmark((char)(sEXPRSTART+argpos));/* mark beginning of new expression in stage */ - if (arglist[argpos]!=ARG_UNHANDLED) - error(58); /* argument already set */ - if (!pending_this && matchtoken('_')) { - arglist[argpos]=ARG_IGNORED; /* flag argument as "present, but ignored" */ - if (arg[argidx].ident==0 || arg[argidx].ident==iVARARGS) { - error(92); /* argument count mismatch */ - } else if (!arg[argidx].hasdefault) { - error(34,nargs+1); /* argument has no default value */ - } /* if */ - if (arg[argidx].ident!=0 && arg[argidx].ident!=iVARARGS) - argidx++; - /* The rest of the code to handle default values is at the bottom - * of this routine where default values for unspecified parameters - * are (also) handled. Note that above, the argument is flagged as - * ARG_IGNORED. - */ - } else { - arglist[argpos]=ARG_DONE; /* flag argument as "present" */ - if (arg[argidx].ident!=0 && arg[argidx].numtags==1) /* set the expected tag, if any */ - lval.cmptag=arg[argidx].tags[0]; - if (pending_this) { - lval = implicitthis->val; - lvalue = implicitthis->lvalue; - } else { - lvalue = hier14(&lval); - if (lvalue && lval.ident == iACCESSOR) { - rvalue(&lval); - lvalue = FALSE; - } - } - assert(sc_status==statFIRST || arg[argidx].ident == 0 || arg[argidx].tags!=NULL); - switch (arg[argidx].ident) { - case 0: - /* On the first pass, we donm't have all of the parameter info. - * Hpwever, use information must be marked anyway, otherwise vars - * declared previously will be omitted in the second psas. See - * SourceMod bug 4643. - */ - error(92); /* argument count mismatch */ - if (lval.sym) - markusage(lval.sym, uREAD); - break; - case iVARARGS: - /* always pass by reference */ - if (lval.ident==iVARIABLE || lval.ident==iREFERENCE) { - assert(lval.sym!=NULL); - if ((lval.sym->usage & uCONST)!=0 && (arg[argidx].usage & uCONST)==0) { - /* treat a "const" variable passed to a function with a non-const - * "variable argument list" as a constant here */ - if (!lvalue) { - error(22); /* need lvalue */ - } else { - rvalue(&lval); /* get value in PRI */ - setheap_pri(); /* address of the value on the heap in PRI */ - heapalloc+=markheap(MEMUSE_STATIC, 1); - nest_stkusage++; - } /* if */ - } else if (lvalue) { - address(lval.sym,sPRI); - } else { - setheap_pri(); /* address of the value on the heap in PRI */ - heapalloc+=markheap(MEMUSE_STATIC, 1); - nest_stkusage++; - } /* if */ - } else if (lval.ident==iCONSTEXPR || lval.ident==iEXPRESSION) - { - /* allocate a cell on the heap and store the - * value (already in PRI) there */ - setheap_pri(); /* address of the value on the heap in PRI */ - heapalloc+=markheap(MEMUSE_STATIC, 1); - nest_stkusage++; - } /* if */ - /* ??? handle const array passed by reference */ - /* otherwise, the address is already in PRI */ - if (lval.sym!=NULL) - markusage(lval.sym,uWRITTEN); - if (!checktags_string(arg[argidx].tags, arg[argidx].numtags, &lval) - && !checktag(arg[argidx].tags,arg[argidx].numtags,lval.tag)) - error(213); - break; - case iVARIABLE: - if (lval.ident==iLABEL || lval.ident==iFUNCTN || lval.ident==iREFFUNC - || lval.ident==iARRAY || lval.ident==iREFARRAY) - error(35,argidx+1); /* argument type mismatch */ - if (lvalue) - rvalue(&lval); /* get value (direct or indirect) */ - /* otherwise, the expression result is already in PRI */ - assert(arg[argidx].numtags>0); - check_userop(NULL,lval.tag,arg[argidx].tags[0],2,NULL,&lval.tag); - if (!checktags_string(arg[argidx].tags, arg[argidx].numtags, &lval)) - checktag(arg[argidx].tags, arg[argidx].numtags, lval.tag); - if (lval.tag!=0) - append_constval(&taglst,arg[argidx].name,lval.tag,0); - argidx++; /* argument done */ - break; - case iREFERENCE: - if (!lvalue) - error(35,argidx+1); /* argument type mismatch */ - if (lval.sym!=NULL && (lval.sym->usage & uCONST)!=0 && (arg[argidx].usage & uCONST)==0) - error(35,argidx+1); /* argument type mismatch */ - if (lval.ident==iVARIABLE || lval.ident==iREFERENCE) { - if (lvalue) { - assert(lval.sym!=NULL); - address(lval.sym,sPRI); - } else { - setheap_pri(); /* address of the value on the heap in PRI */ - heapalloc+=markheap(MEMUSE_STATIC, 1); - nest_stkusage++; - } /* if */ - } /* if */ - /* otherwise, the address is already in PRI */ - checktag(arg[argidx].tags,arg[argidx].numtags,lval.tag); - if (lval.tag!=0) - append_constval(&taglst,arg[argidx].name,lval.tag,0); - argidx++; /* argument done */ - if (lval.sym!=NULL) - markusage(lval.sym,uWRITTEN); - break; - case iREFARRAY: - if (lval.ident!=iARRAY && lval.ident!=iREFARRAY - && lval.ident!=iARRAYCELL && lval.ident!=iARRAYCHAR) - { - error(35,argidx+1); /* argument type mismatch */ - break; - } /* if */ - if (lval.sym!=NULL && (lval.sym->usage & uCONST)!=0 && (arg[argidx].usage & uCONST)==0) - error(35,argidx+1); /* argument type mismatch */ - /* Verify that the dimensions match with those in arg[argidx]. - * A literal array always has a single dimension. - * An iARRAYCELL parameter is also assumed to have a single dimension. - */ - if (lval.sym==NULL || lval.ident==iARRAYCELL || lval.ident==iARRAYCHAR) { - if (arg[argidx].numdim!=1) { - error(48); /* array dimensions must match */ - } else if (arg[argidx].dim[0]!=0) { - assert(arg[argidx].dim[0]>0); - if (lval.ident==iARRAYCELL) { - error(47); /* array sizes must match */ - } else { - assert(lval.constval!=0); /* literal array must have a size */ - /* A literal array must have exactly the same size as the - * function argument; a literal string may be smaller than - * the function argument. - */ - if ((lval.constval>0 && arg[argidx].dim[0]!=lval.constval) - || (lval.constval<0 && arg[argidx].dim[0] < -lval.constval)) - error(47); /* array sizes must match */ - } /* if */ - } /* if */ - if (lval.ident!=iARRAYCELL && lval.ident!=iARRAYCHAR) { - /* save array size, for default values with uSIZEOF flag */ - cell array_sz=lval.constval; - assert(array_sz!=0);/* literal array must have a size */ - if (array_sz<0) - array_sz= -array_sz; - append_constval(&arrayszlst,arg[argidx].name,array_sz,0); - }/* if */ - } else { - symbol *sym=lval.sym; - short level=0; - assert(sym!=NULL); - if (sym->dim.array.level+1!=arg[argidx].numdim) - error(48); /* array dimensions must match */ - /* the lengths for all dimensions must match, unless the dimension - * length was defined at zero (which means "undefined") - */ - while (sym->dim.array.level>0) { - assert(leveldim.array.length!=arg[argidx].dim[level]) - error(47); /* array sizes must match */ - else if (!matchtag(arg[argidx].idxtag[level],sym->x.tags.index,TRUE)) - error(229,sym->name); /* index tag mismatch */ - append_constval(&arrayszlst,arg[argidx].name,sym->dim.array.length,level); - sym=finddepend(sym); - assert(sym!=NULL); - level++; - } /* if */ - /* the last dimension is checked too, again, unless it is zero */ - assert(leveldim.array.length!=arg[argidx].dim[level]) - error(47); /* array sizes must match */ - else if (!matchtag(arg[argidx].idxtag[level],sym->x.tags.index,TRUE)) - error(229,sym->name); /* index tag mismatch */ - append_constval(&arrayszlst,arg[argidx].name,sym->dim.array.length,level); - } /* if */ - /* address already in PRI */ - - checktag(arg[argidx].tags,arg[argidx].numtags,lval.tag); - - if (arg[argidx].numtags > 0) { - if ((arg[argidx].tags[0] != pc_tag_string && lval.tag == pc_tag_string) || - (arg[argidx].tags[0] == pc_tag_string && lval.tag != pc_tag_string)) - { - error(178, type_to_name(lval.tag), type_to_name(arg[argidx].tags[0])); - } - } - - if (lval.tag!=0) - append_constval(&taglst,arg[argidx].name,lval.tag,0); - // ??? set uWRITTEN? - argidx++; /* argument done */ - break; - } /* switch */ - pushreg(sPRI); /* store the function argument on the stack */ - markexpr(sPARM,NULL,0); /* mark the end of a sub-expression */ - nest_stkusage++; - } /* if */ - assert(arglist[argpos]!=ARG_UNHANDLED); - nargs++; - - /** - * We can already have decided it was time to close because of pending_this. - * If that's the case, then bail out now. - */ - if (pending_this && close) { - pending_this = FALSE; - break; - } - - if (matchparanthesis) { - close=matchtoken(')'); - if (!close) /* if not paranthese... */ - /* Not expecting comma if the first argument was implicit. */ - if (!pending_this && !needtoken(',')) - break; /* ...but abort loop if neither */ - } else { - /* Not expecting comma if the first argument was implicit. */ - close = (!pending_this && !matchtoken(',')); - if (close) { /* if not comma... */ - if (needtoken(tTERM)==1)/* ...must be end of statement */ - lexpush(); /* push again, because end of statement is analised later */ - } /* if */ - } /* if */ - - pending_this = FALSE; - } while (!close && freading && !matchtoken(tENDEXPR)); /* do */ - } /* if */ - /* check remaining function arguments (they may have default values) */ - for (argidx=0; arg[argidx].ident!=0 && arg[argidx].ident!=iVARARGS; argidx++) { - if (arglist[argidx]==ARG_DONE) - continue; /* already seen and handled this argument */ - /* in this first stage, we also skip the arguments with uSIZEOF and uTAGOF; - * these are handled last - */ - if ((arg[argidx].hasdefault & uSIZEOF)!=0 || (arg[argidx].hasdefault & uTAGOF)!=0) { - assert(arg[argidx].ident==iVARIABLE); - continue; - } /* if */ - stgmark((char)(sEXPRSTART+argidx));/* mark beginning of new expression in stage */ - if (arg[argidx].hasdefault) { - if (arg[argidx].ident==iREFARRAY) { - short level; - setdefarray(arg[argidx].defvalue.array.data, - arg[argidx].defvalue.array.size, - arg[argidx].defvalue.array.arraysize, - &arg[argidx].defvalue.array.addr, - (arg[argidx].usage & uCONST)!=0); - if (arg[argidx].defvalue.array.data != NULL) { - if ((arg[argidx].usage & uCONST)==0) { - heapalloc+=arg[argidx].defvalue.array.arraysize; - nest_stkusage+=arg[argidx].defvalue.array.arraysize; - } /* if */ - /* keep the lengths of all dimensions of a multi-dimensional default array */ - assert(arg[argidx].numdim>0); - if (arg[argidx].numdim==1) { - append_constval(&arrayszlst,arg[argidx].name,arg[argidx].defvalue.array.arraysize,0); - } else { - for (level=0; level0); - check_userop(NULL,arg[argidx].defvalue_tag,arg[argidx].tags[0],2,NULL,&dummytag); - assert(dummytag==arg[argidx].tags[0]); - } /* if */ - pushreg(sPRI); /* store the function argument on the stack */ - markexpr(sPARM,NULL,0); /* mark the end of a sub-expression */ - nest_stkusage++; - } else { - error(92,argidx); /* argument count mismatch */ - } /* if */ - if (arglist[argidx]==ARG_UNHANDLED) - nargs++; - arglist[argidx]=ARG_DONE; - } /* for */ - /* now a second loop to catch the arguments with default values that are - * the "sizeof" or "tagof" of other arguments - */ - for (argidx=0; arg[argidx].ident!=0 && arg[argidx].ident!=iVARARGS; argidx++) { - constvalue *asz; - cell array_sz; - if (arglist[argidx]==ARG_DONE) - continue; /* already seen and handled this argument */ - stgmark((char)(sEXPRSTART+argidx));/* mark beginning of new expression in stage */ - assert(arg[argidx].ident==iVARIABLE); /* if "sizeof", must be single cell */ - /* if unseen, must be "sizeof" or "tagof" */ - assert((arg[argidx].hasdefault & uSIZEOF)!=0 || (arg[argidx].hasdefault & uTAGOF)!=0); - if ((arg[argidx].hasdefault & uSIZEOF)!=0) { - /* find the argument; if it isn't found, the argument's default value - * was a "sizeof" of a non-array (a warning for this was already given - * when declaring the function) - */ - asz=find_constval(&arrayszlst,arg[argidx].defvalue.size.symname, - arg[argidx].defvalue.size.level); - if (asz!=NULL) { - array_sz=asz->value; - if (array_sz==0) - error(163,arg[argidx].name); /* indeterminate array size in "sizeof" expression */ - } else { - array_sz=1; - } /* if */ - } else { - asz=find_constval(&taglst,arg[argidx].defvalue.size.symname, - arg[argidx].defvalue.size.level); - if (asz != NULL) { - array_sz=asz->value; /* must be set, because it just was exported */ - } else { - array_sz=0; - } /* if */ - } /* if */ - ldconst(array_sz,sPRI); - pushreg(sPRI); /* store the function argument on the stack */ - markexpr(sPARM,NULL,0); - nest_stkusage++; - if (arglist[argidx]==ARG_UNHANDLED) - nargs++; - arglist[argidx]=ARG_DONE; - } /* for */ - stgmark(sENDREORDER); /* mark end of reversed evaluation */ - pushval((cell)nargs /* *sizeof(cell)*/ ); - nest_stkusage++; - ffcall(sym,NULL,nargs); - if (sc_status!=statSKIP) - markusage(sym,uREAD); /* do not mark as "used" when this call itself is skipped */ - if ((sym->usage & uNATIVE)!=0 &&sym->x.lib!=NULL) - sym->x.lib->value += 1; /* increment "usage count" of the library */ - if (symret!=NULL) - popreg(sPRI); /* pop hidden parameter as function result */ - sideeffect=TRUE; /* assume functions carry out a side-effect */ - delete_consttable(&arrayszlst); /* clear list of array sizes */ - delete_consttable(&taglst); /* clear list of parameter tags */ - - /* maintain max. amount of memory used */ - { - long totalsize; - totalsize=declared+heapalloc+1; /* local variables & return value size, - * +1 for PROC opcode */ - if (lval_result->ident==iREFARRAY) - totalsize++; /* add hidden parameter (on the stack) */ - if ((sym->usage & uNATIVE)==0) - totalsize++; /* add "call" opcode */ - totalsize+=nest_stkusage; - if (curfunc != NULL) { - if (curfunc->x.stacksizex.stacksize=totalsize; - } else { - error(10); - } - nest_stkusage-=nargs+heapalloc+1; /* stack/heap space, +1 for argcount param */ - /* if there is a syntax error in the script, the stack calculation is - * probably incorrect; but we may not allow it to drop below zero - */ - if (nest_stkusage<0) - nest_stkusage=0; - } - - /* scrap any arrays left on the heap, with the exception of the array that - * this function has as a result (in other words, scrap all arrays on the - * heap that caused by expressions in the function arguments) - */ - popheaplist(); - nesting--; -} - -/* dbltest - * - * Returns a non-zero value if lval1 an array and lval2 is not an array and - * the operation is addition or subtraction. - * - * Returns the "shift" count (1 for 16-bit, 2 for 32-bit) to align a cell - * to an array offset. - */ -static int dbltest(void (*oper)(),value *lval1,value *lval2) -{ - if ((oper!=ob_add) && (oper!=ob_sub)) - return 0; - if (lval1->ident!=iARRAY) - return 0; - if (lval2->ident==iARRAY) - return 0; - return sizeof(cell)/2; /* 1 for 16-bit, 2 for 32-bit */ -} - -/* commutative - * - * Test whether an operator is commutative, i.e. x oper y == y oper x. - * Commutative operators are: + (addition) - * * (multiplication) - * == (equality) - * != (inequality) - * & (bitwise and) - * ^ (bitwise xor) - * | (bitwise or) - * - * If in an expression, code for the left operand has been generated and - * the right operand is a constant and the operator is commutative, the - * precautionary "push" of the primary register is scrapped and the constant - * is read into the secondary register immediately. - */ -static int commutative(void (*oper)()) -{ - return oper==ob_add || oper==os_mult - || oper==ob_eq || oper==ob_ne - || oper==ob_and || oper==ob_xor || oper==ob_or; -} - -/* constant - * - * Generates code to fetch a number, a literal character (which is returned - * by lex() as a number as well) or a literal string (lex() stores the - * strings in the literal queue). If the operand was a number, it is stored - * in lval->constval. - * - * The function returns 1 if the token was a constant or a string, 0 - * otherwise. - */ -static int constant(value *lval) -{ - int tok,index,ident; - cell val,item,cidx; - char *st; - symbol *sym; - int cmptag=lval->cmptag; - - tok=lex(&val,&st); - if (tok==tSYMBOL && (sym=findconst(st,&cmptag))!=0) { - if (cmptag>1) - error(91,sym->name); /* ambiguity: multiple matching constants (different tags) */ - lval->constval=sym->addr; - ldconst(lval->constval,sPRI); - lval->ident=iCONSTEXPR; - lval->tag=sym->tag; - lval->sym=sym; - markusage(sym,uREAD); - } else if (tok==tNULL) { - lval->constval = 0; - ldconst(lval->constval, sPRI); - lval->ident = iCONSTEXPR; - lval->tag = pc_tag_null_t; - } else if (tok==tNUMBER) { - lval->constval=val; - ldconst(lval->constval,sPRI); - lval->ident=iCONSTEXPR; - } else if (tok==tRATIONAL) { - lval->constval=val; - ldconst(lval->constval,sPRI); - lval->ident=iCONSTEXPR; - lval->tag=sc_rationaltag; - } else if (tok==tSTRING) { - /* lex() stores starting index of string in the literal table in 'val' */ - ldconst((val+glb_declared)*sizeof(cell),sPRI); - lval->ident=iARRAY; /* pretend this is a global array */ - lval->constval=val-litidx; /* constval == the negative value of the - * size of the literal array; using a negative - * value distinguishes between literal arrays - * and literal strings (this was done for - * array assignment). */ - lval->tag=pc_tag_string; - } else if (tok=='{') { - int tag,lasttag=-1; - val=litidx; - do { - /* cannot call constexpr() here, because "staging" is already turned - * on at this point */ - assert(staging); - stgget(&index,&cidx); /* mark position in code generator */ - ident=expression(&item,&tag,NULL,FALSE,NULL); - stgdel(index,cidx); /* scratch generated code */ - if (ident!=iCONSTEXPR) - error(8); /* must be constant expression */ - if (lasttag<0) - lasttag=tag; - else - matchtag(lasttag,tag,FALSE); - litadd(item); /* store expression result in literal table */ - } while (matchtoken(',')); - if (!needtoken('}')) - lexclr(FALSE); - ldconst((val+glb_declared)*sizeof(cell),sPRI); - lval->ident=iARRAY; /* pretend this is a global array */ - lval->constval=litidx-val; /* constval == the size of the literal array */ - } else { - return FALSE; /* no, it cannot be interpreted as a constant */ - } /* if */ - return TRUE; /* yes, it was a constant value */ -} - diff --git a/sourcepawn/compiler/sc4.cpp b/sourcepawn/compiler/sc4.cpp deleted file mode 100644 index 1c0a35bf..00000000 --- a/sourcepawn/compiler/sc4.cpp +++ /dev/null @@ -1,1504 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -/* Pawn compiler - code generation (unoptimized "assembler" code) - * - * Copyright (c) ITB CompuPhase, 1997-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include -#include -#include /* for _MAX_PATH */ -#include -#if defined FORTIFY - #include -#endif -#include "sc.h" -#include "sctracker.h" - -static int fcurseg; /* the file number (fcurrent) for the active segment */ - -void load_i(); - -/* When a subroutine returns to address 0, the AMX must halt. In earlier - * releases, the RET and RETN opcodes checked for the special case 0 address. - * Today, the compiler simply generates a HALT instruction at address 0. So - * a subroutine can savely return to 0, and then encounter a HALT. - */ -void writeleader(symbol *root) -{ - int lbl_nostate,lbl_table; - int statecount; - symbol *sym; - constvalue *fsa, *state, *stlist; - int fsa_id,listid; - char lbl_default[sNAMEMAX+1]; - - assert(code_idx==0); - - begcseg(); - stgwrite(";program exit point\n"); - stgwrite("\thalt 0\n\n"); - code_idx+=opcodes(1)+opargs(1); /* calculate code length */ - - /* check whether there are any functions that have states */ - for (sym=root->next; sym!=NULL; sym=sym->next) - if (sym->ident==iFUNCTN && (sym->usage & (uPUBLIC | uREAD))!=0 && sym->states!=NULL) - break; - if (sym==NULL) - return; /* no function has states, nothing to do next */ - - /* generate an error function that is called for an undefined state */ - stgwrite("\n;exit point for functions called from the wrong state\n"); - lbl_nostate=getlabel(); - setlabel(lbl_nostate); - stgwrite("\thalt "); - outval(AMX_ERR_INVSTATE,TRUE); - code_idx+=opcodes(1)+opargs(1); /* calculate code length */ - - /* write the "state-selectors" table with all automatons (update the - * automatons structure too, as we are now assigning the address to - * each automaton state-selector variable) - */ - assert(glb_declared==0); - begdseg(); - for (fsa=sc_automaton_tab.next; fsa!=NULL; fsa=fsa->next) { - defstorage(); - stgwrite("0\t; automaton "); - if (strlen(fsa->name)==0) - stgwrite("(anonymous)"); - else - stgwrite(fsa->name); - stgwrite("\n"); - fsa->value=glb_declared*sizeof(cell); - glb_declared++; - } /* for */ - - /* write stubs and jump tables for all state functions */ - begcseg(); - for (sym=root->next; sym!=NULL; sym=sym->next) { - if (sym->ident==iFUNCTN && (sym->usage & (uPUBLIC | uREAD))!=0 && sym->states!=NULL) { - stlist=sym->states->next; - assert(stlist!=NULL); /* there should be at least one state item */ - listid=stlist->index; - assert(listid==-1 || listid>0); - if (listid==-1 && stlist->next!=NULL) { - /* first index is the "fallback", take the next one (if available) */ - stlist=stlist->next; - listid=stlist->index; - } /* if */ - if (listid==-1) { - /* first index is the fallback, there is no second... */ - strcpy(stlist->name,"0"); /* insert dummy label number */ - /* this is an error, but we postpone adding the error message until the - * function definition - */ - continue; - } /* if */ - /* generate label numbers for all statelist ids */ - for (stlist=sym->states->next; stlist!=NULL; stlist=stlist->next) { - assert(strlen(stlist->name)==0); - strcpy(stlist->name,itoh(getlabel())); - } /* for */ - if (strcmp(sym->name,uENTRYFUNC)==0) - continue; /* do not generate stubs for this special function */ - sym->addr=code_idx; /* fix the function address now */ - /* get automaton id for this function */ - assert(listid>0); - fsa_id=state_getfsa(listid); - assert(fsa_id>=0); /* automaton 0 exists */ - fsa=automaton_findid(fsa_id); - /* count the number of states actually used; at the sane time, check - * whether there is a default state function - */ - statecount=0; - strcpy(lbl_default,itoh(lbl_nostate)); - for (stlist=sym->states->next; stlist!=NULL; stlist=stlist->next) { - if (stlist->index==-1) { - assert(strlen(stlist->name)name); - } else { - statecount+=state_count(stlist->index); - } /* if */ - } /* for */ - /* generate a stub entry for the functions */ - stgwrite("\tload.pri "); - outval(fsa->value,FALSE); - stgwrite("\t; "); - stgwrite(sym->name); - stgwrite("\n"); - code_idx+=opcodes(1)+opargs(1); /* calculate code length */ - lbl_table=getlabel(); - ffswitch(lbl_table); - /* generate the jump table */ - setlabel(lbl_table); - ffcase(statecount,lbl_default,TRUE); - for (state=sc_state_tab.next; state!=NULL; state=state->next) { - if (state->index==fsa_id) { - /* find the label for this list id */ - for (stlist=sym->states->next; stlist!=NULL; stlist=stlist->next) { - if (stlist->index!=-1 && state_inlist(stlist->index,(int)state->value)) { - ffcase(state->value,stlist->name,FALSE); - break; - } /* if */ - } /* for */ - if (stlist==NULL && strtol(lbl_default,NULL,16)==lbl_nostate) - error(230,state->name,sym->name); /* unimplemented state, no fallback */ - } /* if (state belongs to automaton of function) */ - } /* for (state) */ - stgwrite("\n"); - } /* if (is function, used & having states) */ - } /* for (sym) */ -} - -/* writetrailer - * Not much left of this once important function. - * - * Global references: pc_stksize (referred to only) - * sc_dataalign (referred to only) - * code_idx (altered) - * glb_declared (altered) - */ -void writetrailer(void) -{ - assert(sc_dataalign % opcodes(1) == 0); /* alignment must be a multiple of - * the opcode size */ - assert(sc_dataalign!=0); - - /* pad code to align data segment */ - if ((code_idx % sc_dataalign)!=0) { - begcseg(); - while ((code_idx % sc_dataalign)!=0) - nooperation(); - } /* if */ - - /* pad data segment to align the stack and the heap */ - assert(litidx==0); /* literal queue should have been emptied */ - assert(sc_dataalign % sizeof(cell) == 0); - if (((glb_declared*sizeof(cell)) % sc_dataalign)!=0) { - begdseg(); - defstorage(); - while (((glb_declared*sizeof(cell)) % sc_dataalign)!=0) { - stgwrite("0 "); - glb_declared++; - } /* while */ - } /* if */ - - stgwrite("\nSTKSIZE "); /* write stack size (align stack top) */ - outval(pc_stksize - (pc_stksize % sc_dataalign), TRUE); -} - -/* - * Start (or restart) the CODE segment. - * - * In fact, the code and data segment specifiers are purely informational; - * the "DUMP" instruction itself already specifies that the following values - * should go to the data segment. All other instructions go to the code - * segment. - * - * Global references: curseg - * fcurrent - */ -void begcseg(void) -{ - if (sc_status!=statSKIP && (curseg!=sIN_CSEG || fcurrent!=fcurseg)) { - stgwrite("\n"); - stgwrite("CODE "); - outval(fcurrent,FALSE); - stgwrite("\t; "); - outval(code_idx,TRUE); - curseg=sIN_CSEG; - fcurseg=fcurrent; - } /* endif */ -} - -/* - * Start (or restart) the DATA segment. - * - * Global references: curseg - */ -void begdseg(void) -{ - if (sc_status!=statSKIP && (curseg!=sIN_DSEG || fcurrent!=fcurseg)) { - stgwrite("\n"); - stgwrite("DATA "); - outval(fcurrent,FALSE); - stgwrite("\t; "); - outval((glb_declared-litidx)*sizeof(cell),TRUE); - curseg=sIN_DSEG; - fcurseg=fcurrent; - } /* if */ -} - -void setline(int chkbounds) -{ - if (sc_asmfile) { - stgwrite("\t; line "); - outval(fline,TRUE); - } /* if */ - if ((sc_debug & sSYMBOLIC)!=0 || (chkbounds && (sc_debug & sCHKBOUNDS)!=0)) { - /* generate a "break" (start statement) opcode rather than a "line" opcode - * because earlier versions of Small/Pawn have an incompatible version of the - * line opcode - */ - stgwrite("\tbreak\t; "); - outval(code_idx,TRUE); - code_idx+=opcodes(1); - } /* if */ -} - -void setfiledirect(char *name) -{ - if (sc_status==statFIRST && sc_listing) { - assert(name!=NULL); - pc_writeasm(outf,"#file "); - pc_writeasm(outf,name); - pc_writeasm(outf,"\n"); - } /* if */ -} - -void setlinedirect(int line) -{ - if (sc_status==statFIRST && sc_listing) { - char string[40]; - sprintf(string,"#line %d\n",line); - pc_writeasm(outf,string); - } /* if */ -} - -/* setlabel - * - * Post a code label (specified as a number), on a new line. - */ -void setlabel(int number) -{ - assert(number>=0); - stgwrite("l."); - stgwrite((char *)itoh(number)); - /* To assist verification of the assembled code, put the address of the - * label as a comment. However, labels that occur inside an expression - * may move (through optimization or through re-ordering). So write the - * address only if it is known to accurate. - */ - if (!staging) { - stgwrite("\t\t; "); - outval(code_idx,FALSE); - } /* if */ - stgwrite("\n"); -} - -/* Write a token that signifies the start or end of an expression or special - * statement. This allows several simple optimizations by the peephole - * optimizer. - */ -void markexpr(optmark type,const char *name,cell offset) -{ - switch (type) { - case sEXPR: - stgwrite("\t;$exp\n"); - break; - case sPARM: - stgwrite("\t;$par\n"); - break; - case sLDECL: - assert(name!=NULL); - stgwrite("\t;$lcl "); - stgwrite(name); - stgwrite(" "); - outval(offset,TRUE); - break; - default: - assert(0); - } /* switch */ -} - -/* startfunc - declare a CODE entry point (function start) - * - * Global references: funcstatus (referred to only) - */ -void startfunc(char *fname) -{ - stgwrite("\tproc"); - if (sc_asmfile) { - char symname[2*sNAMEMAX+16]; - funcdisplayname(symname,fname); - stgwrite("\t; "); - stgwrite(symname); - } /* if */ - stgwrite("\n"); - code_idx+=opcodes(1); -} - -/* endfunc - * - * Declare a CODE ending point (function end) - */ -void endfunc(void) -{ - stgwrite("\n"); /* skip a line */ -} - -/* alignframe - * - * Aligns the frame (and the stack) of the current function to a multiple - * of the specified byte count. Two caveats: the alignment ("numbytes") should - * be a power of 2, and this alignment must be done right after the frame - * is set up (before the first variable is declared) - */ -void alignframe(int numbytes) -{ - #if !defined NDEBUG - /* "numbytes" should be a power of 2 for this code to work */ - int i,count=0; - for (i=0; isym; - if (lval->ident==iARRAYCELL) { - /* indirect fetch, address already in PRI */ - load_i(); - } else if (lval->ident==iARRAYCHAR) { - /* indirect fetch of a character from a pack, address already in PRI */ - stgwrite("\tlodb.i "); - outval(sCHARBITS/8,TRUE); /* read one or two bytes */ - code_idx+=opcodes(1)+opargs(1); - } else if (lval->ident==iREFERENCE) { - /* indirect fetch, but address not yet in PRI */ - assert(sym!=NULL); - assert(sym->vclass==sLOCAL);/* global references don't exist in Pawn */ - if (sym->vclass==sLOCAL) - stgwrite("\tlref.s.pri "); - else - stgwrite("\tlref.pri "); - outval(sym->addr,TRUE); - markusage(sym,uREAD); - code_idx+=opcodes(1)+opargs(1); - } else if (lval->ident==iACCESSOR) { - invoke_getter(lval->accessor); - lval->ident=iEXPRESSION; - lval->accessor=NULL; - } else { - /* direct or stack relative fetch */ - assert(sym!=NULL); - if (sym->vclass==sLOCAL) - stgwrite("\tload.s.pri "); - else - stgwrite("\tload.pri "); - outval(sym->addr,TRUE); - markusage(sym,uREAD); - code_idx+=opcodes(1)+opargs(1); - } /* if */ -} - -/* Get the address of a symbol into the primary or alternate register (used - * for arrays, and for passing arguments by reference). - */ -void address(symbol *sym,regid reg) -{ - assert(sym!=NULL); - assert(reg==sPRI || reg==sALT); - /* the symbol can be a local array, a global array, or an array - * that is passed by reference. - */ - if (sym->ident==iREFARRAY || sym->ident==iREFERENCE) { - /* reference to a variable or to an array; currently this is - * always a local variable */ - switch (reg) { - case sPRI: - stgwrite("\tload.s.pri "); - break; - case sALT: - stgwrite("\tload.s.alt "); - break; - } /* switch */ - } else { - /* a local array or local variable */ - switch (reg) { - case sPRI: - if (sym->vclass==sLOCAL) - stgwrite("\taddr.pri "); - else - stgwrite("\tconst.pri "); - break; - case sALT: - if (sym->vclass==sLOCAL) - stgwrite("\taddr.alt "); - else - stgwrite("\tconst.alt "); - break; - } /* switch */ - } /* if */ - outval(sym->addr,TRUE); - markusage(sym,uREAD); - code_idx+=opcodes(1)+opargs(1); -} - -static void addr_reg(int val, regid reg) -{ - if (reg == sPRI) - stgwrite("\taddr.pri "); - else - stgwrite("\taddr.alt "); - outval(val, TRUE); - code_idx += opcodes(1) + opargs(1); -} - -// Load the number of arguments into PRI. Frame layout: -// base + 0*sizeof(cell) == previous "base" -// base + 1*sizeof(cell) == function return address -// base + 2*sizeof(cell) == number of arguments -// base + 3*sizeof(cell) == first argument of the function -static void load_argcount(regid reg) -{ - if (reg == sPRI) - stgwrite("\tload.s.pri "); - else - stgwrite("\tload.s.alt "); - outval(2 * sizeof(cell), TRUE); - code_idx += opcodes(1) + opargs(1); -} - -// PRI = ALT + (PRI * cellsize) -void idxaddr() -{ - stgwrite("\tidxaddr\n"); - code_idx += opcodes(1); -} - -void load_i() -{ - stgwrite("\tload.i\n"); - code_idx+=opcodes(1); -} - -// Load the hidden array argument into ALT. -void load_hidden_arg() -{ - pushreg(sPRI); - - // Compute an address to the first argument, then add the argument count - // to find the address after the final argument: - // addr.alt 0xc ; Compute &first_arg - // load.s.alt 0x8 ; Load arg count - // idxaddr ; Compute (&first_arg) + argcount - // load.i ; Load *(&first_arg + argcount) - // move.alt ; Move result into ALT. - addr_reg(0xc, sALT); - load_argcount(sPRI); - idxaddr(); - load_i(); - move_alt(); - - popreg(sPRI); -} - -/* store - * - * Saves the contents of "primary" into a memory cell, either directly - * or indirectly (at the address given in the alternate register). - */ -void store(value *lval) -{ - symbol *sym; - - sym=lval->sym; - if (lval->ident==iARRAYCELL) { - /* store at address in ALT */ - stgwrite("\tstor.i\n"); - code_idx+=opcodes(1); - } else if (lval->ident==iARRAYCHAR) { - /* store at address in ALT */ - stgwrite("\tstrb.i "); - outval(sCHARBITS/8,TRUE); /* write one or two bytes */ - code_idx+=opcodes(1)+opargs(1); - } else if (lval->ident==iREFERENCE) { - assert(sym!=NULL); - if (sym->vclass==sLOCAL) - stgwrite("\tsref.s.pri "); - else - stgwrite("\tsref.pri "); - outval(sym->addr,TRUE); - code_idx+=opcodes(1)+opargs(1); - } else if (lval->ident==iACCESSOR) { - invoke_setter(lval->accessor, TRUE); - } else { - assert(sym!=NULL); - markusage(sym,uWRITTEN); - if (sym->vclass==sLOCAL) - stgwrite("\tstor.s.pri "); - else - stgwrite("\tstor.pri "); - outval(sym->addr,TRUE); - code_idx+=opcodes(1)+opargs(1); - } /* if */ -} - -/* Get a cell from a fixed address in memory */ -void loadreg(cell address,regid reg) -{ - assert(reg==sPRI || reg==sALT); - if (reg==sPRI) - stgwrite("\tload.pri "); - else - stgwrite("\tload.alt "); - outval(address,TRUE); - code_idx+=opcodes(1)+opargs(1); -} - -/* Store a cell into a fixed address in memory */ -void storereg(cell address,regid reg) -{ - assert(reg==sPRI || reg==sALT); - if (reg==sPRI) - stgwrite("\tstor.pri "); - else - stgwrite("\tstor.alt "); - outval(address,TRUE); - code_idx+=opcodes(1)+opargs(1); -} - -/* source must in PRI, destination address in ALT. The "size" - * parameter is in bytes, not cells. - */ -void memcopy(cell size) -{ - stgwrite("\tmovs "); - outval(size,TRUE); - - code_idx+=opcodes(1)+opargs(1); -} - -/* Address of the source must already have been loaded in PRI - * "size" is the size in bytes (not cells). - */ -void copyarray(symbol *sym,cell size) -{ - assert(sym!=NULL); - /* the symbol can be a local array, a global array, or an array - * that is passed by reference. - */ - if (sym->ident==iREFARRAY) { - /* reference to an array; currently this is always a local variable */ - assert(sym->vclass==sLOCAL); /* symbol must be stack relative */ - stgwrite("\tload.s.alt "); - } else { - /* a local or global array */ - if (sym->vclass==sLOCAL) - stgwrite("\taddr.alt "); - else - stgwrite("\tconst.alt "); - } /* if */ - outval(sym->addr,TRUE); - markusage(sym,uWRITTEN); - - code_idx+=opcodes(1)+opargs(1); - memcopy(size); -} - -void fillarray(symbol *sym,cell size,cell value) -{ - ldconst(value,sPRI); /* load value in PRI */ - - assert(sym!=NULL); - /* the symbol can be a local array, a global array, or an array - * that is passed by reference. - */ - if (sym->ident==iREFARRAY) { - /* reference to an array; currently this is always a local variable */ - assert(sym->vclass==sLOCAL); /* symbol must be stack relative */ - stgwrite("\tload.s.alt "); - } else { - /* a local or global array */ - if (sym->vclass==sLOCAL) - stgwrite("\taddr.alt "); - else - stgwrite("\tconst.alt "); - } /* if */ - outval(sym->addr,TRUE); - markusage(sym,uWRITTEN); - - assert(size>0); - stgwrite("\tfill "); - outval(size,TRUE); - - code_idx+=opcodes(2)+opargs(2); -} - -void stradjust(regid reg) -{ - assert(reg==sPRI); - stgwrite("\tstradjust.pri\n"); - code_idx+=opcodes(1); -} - -/* Instruction to get an immediate value into the primary or the alternate - * register - */ -void ldconst(cell val,regid reg) -{ - assert(reg==sPRI || reg==sALT); - switch (reg) { - case sPRI: - if (val==0) { - stgwrite("\tzero.pri\n"); - code_idx+=opcodes(1); - } else { - stgwrite("\tconst.pri "); - outval(val, TRUE); - code_idx+=opcodes(1)+opargs(1); - } /* if */ - break; - case sALT: - if (val==0) { - stgwrite("\tzero.alt\n"); - code_idx+=opcodes(1); - } else { - stgwrite("\tconst.alt "); - outval(val, TRUE); - code_idx+=opcodes(1)+opargs(1); - } /* if */ - break; - } /* switch */ -} - -/* Copy value in alternate register to the primary register */ -void moveto1(void) -{ - stgwrite("\tmove.pri\n"); - code_idx+=opcodes(1)+opargs(0); -} - -void move_alt(void) -{ - stgwrite("\tmove.alt\n"); - code_idx+=opcodes(1)+opargs(0); -} - -/* Push primary or the alternate register onto the stack - */ -void pushreg(regid reg) -{ - assert(reg==sPRI || reg==sALT); - switch (reg) { - case sPRI: - stgwrite("\tpush.pri\n"); - break; - case sALT: - stgwrite("\tpush.alt\n"); - break; - } /* switch */ - code_idx+=opcodes(1); -} - -/* - * Push a constant value onto the stack - */ -void pushval(cell val) -{ - stgwrite("\tpush.c "); - outval(val, TRUE); - code_idx+=opcodes(1)+opargs(1); -} - -/* Pop stack into the primary or the alternate register - */ -void popreg(regid reg) -{ - assert(reg==sPRI || reg==sALT); - switch (reg) { - case sPRI: - stgwrite("\tpop.pri\n"); - break; - case sALT: - stgwrite("\tpop.alt\n"); - break; - } /* switch */ - code_idx+=opcodes(1); -} - -/* - * Generate an array - * stk -= dims - * [stk] = hea - * stk += 1 - * hea += 1 + (# cells in array) - */ -void genarray(int dims, int _autozero) -{ - if (_autozero) { - stgwrite("\tgenarray.z "); - } else { - stgwrite("\tgenarray "); - } - outval(dims, TRUE); - code_idx+=opcodes(1)+opargs(1); -} - -/* - * swap the top-of-stack with the value in primary register - */ -void swap1(void) -{ - stgwrite("\tswap.pri\n"); - code_idx+=opcodes(1); -} - -/* Switch statements - * The "switch" statement generates a "case" table using the "CASE" opcode. - * The case table contains a list of records, each record holds a comparison - * value and a label to branch to on a match. The very first record is an - * exception: it holds the size of the table (excluding the first record) and - * the label to branch to when none of the values in the case table match. - * The case table is sorted on the comparison value. This allows more advanced - * abstract machines to sift the case table with a binary search. - */ -void ffswitch(int label) -{ - stgwrite("\tswitch "); - outval(label,TRUE); /* the label is the address of the case table */ - code_idx+=opcodes(1)+opargs(1); -} - -void ffcase(cell value,char *labelname,int newtable) -{ - if (newtable) { - stgwrite("\tcasetbl\n"); - code_idx+=opcodes(1); - } /* if */ - stgwrite("\tcase "); - outval(value,FALSE); - stgwrite(" "); - stgwrite(labelname); - stgwrite("\n"); - code_idx+=opcodes(0)+opargs(2); -} - -/* - * Call specified function - */ -void ffcall(symbol *sym,const char *label,int numargs) -{ - char symname[2*sNAMEMAX+16]; - char aliasname[sNAMEMAX+1]; - int wasAlias = 0; - - assert(sym!=NULL); - assert(sym->ident==iFUNCTN); - if (sc_asmfile) - funcdisplayname(symname,sym->name); - if ((sym->usage & uNATIVE)!=0) { - /* reserve a SYSREQ id if called for the first time */ - assert(label==NULL); - stgwrite("\tsysreq.c "); - if (sc_status==statWRITE && (sym->usage & uREAD)==0 && sym->addr>=0) - sym->addr=ntv_funcid++; - /* Look for an alias */ - if (lookup_alias(aliasname, sym->name)) { - symbol *asym = findglb(aliasname, sGLOBAL); - if (asym && asym->ident==iFUNCTN && ((sym->usage & uNATIVE) != 0)) { - sym = asym; - if (sc_status==statWRITE && (sym->usage & uREAD)==0 && sym->addr>=0) { - sym->addr=ntv_funcid++; - markusage(sym, uREAD); - } - } - } - outval(sym->addr,FALSE); - if (sc_asmfile) { - stgwrite("\t; "); - stgwrite(symname); - } /* if */ - stgwrite("\n"); /* write on a separate line, to mark a sequence point for the peephole optimizer */ - stgwrite("\tstack "); - outval((numargs+1)*sizeof(cell), TRUE); - code_idx+=opcodes(2)+opargs(2); - } else { - /* normal function */ - stgwrite("\tcall "); - if (label!=NULL) { - stgwrite("l."); - stgwrite(label); - } else { - stgwrite(sym->name); - } /* if */ - if (sc_asmfile - && (label!=NULL || (!isalpha(sym->name[0]) && sym->name[0]!='_' && sym->name[0]!=sc_ctrlchar))) - { - stgwrite("\t; "); - stgwrite(symname); - } /* if */ - stgwrite("\n"); - code_idx+=opcodes(1)+opargs(1); - } /* if */ -} - -/* Return from function - * - * Global references: funcstatus (referred to only) - */ -void ffret(int remparams) -{ - if (remparams) - stgwrite("\tretn\n"); - else - stgwrite("\tret\n"); - code_idx+=opcodes(1); -} - -void ffabort(int reason) -{ - stgwrite("\thalt "); - outval(reason,TRUE); - code_idx+=opcodes(1)+opargs(1); -} - -void ffbounds(cell size) -{ - if ((sc_debug & sCHKBOUNDS)!=0) { - stgwrite("\tbounds "); - outval(size,TRUE); - code_idx+=opcodes(1)+opargs(1); - } /* if */ -} - -/* - * Jump to local label number (the number is converted to a name) - */ -void jumplabel(int number) -{ - stgwrite("\tjump "); - outval(number,TRUE); - code_idx+=opcodes(1)+opargs(1); -} - -/* - * Define storage (global and static variables) - */ -void defstorage(void) -{ - stgwrite("dump "); -} - -/* - * Inclrement/decrement stack pointer. Note that this routine does - * nothing if the delta is zero. - */ -void modstk(int delta) -{ - if (delta) { - stgwrite("\tstack "); - outval(delta, TRUE); - code_idx+=opcodes(1)+opargs(1); - } /* if */ -} - -/* set the stack to a hard offset from the frame */ -void setstk(cell value) -{ - stgwrite("\tstackadjust "); - assert(value<=0); /* STK should always become <= FRM */ - outval(value, TRUE); /* add (negative) offset */ - code_idx+=opcodes(1)+opargs(1); -} - -void modheap(int delta) -{ - if (delta) { - stgwrite("\theap "); - outval(delta, TRUE); - code_idx+=opcodes(1)+opargs(1); - } /* if */ -} - -void modheap_i() -{ - stgwrite("\ttracker.pop.setheap\n"); - code_idx+=opcodes(1); -} - -void setheap_save(cell value) -{ - assert(value); - stgwrite("\ttracker.push.c "); - outval(value, TRUE); - code_idx+=opcodes(1)+opargs(1); -} - -void setheap_pri(void) -{ - stgwrite("\theap "); /* ALT = HEA++ */ - outval(sizeof(cell), TRUE); - stgwrite("\tstor.i\n"); /* store PRI (default value) at address ALT */ - stgwrite("\tmove.pri\n"); /* move ALT to PRI: PRI contains the address */ - code_idx+=opcodes(3)+opargs(1); -} - -void setheap(cell value) -{ - stgwrite("\tconst.pri "); /* load default value in PRI */ - outval(value, TRUE); - code_idx+=opcodes(1)+opargs(1); - setheap_pri(); -} - -/* - * Convert a cell number to a "byte" address; i.e. double or quadruple - * the primary register. - */ -void cell2addr(void) -{ - #if PAWN_CELL_SIZE==16 - stgwrite("\tshl.c.pri 1\n"); - #elif PAWN_CELL_SIZE==32 - stgwrite("\tshl.c.pri 2\n"); - #elif PAWN_CELL_SIZE==64 - stgwrite("\tshl.c.pri 3\n"); - #else - #error Unsupported cell size - #endif - code_idx+=opcodes(1)+opargs(1); -} - -/* - * Double or quadruple the alternate register. - */ -void cell2addr_alt(void) -{ - #if PAWN_CELL_SIZE==16 - stgwrite("\tshl.c.alt 1\n"); - #elif PAWN_CELL_SIZE==32 - stgwrite("\tshl.c.alt 2\n"); - #elif PAWN_CELL_SIZE==64 - stgwrite("\tshl.c.alt 3\n"); - #else - #error Unsupported cell size - #endif - code_idx+=opcodes(1)+opargs(1); -} - -/* - * Convert "distance of addresses" to "number of cells" in between. - * Or convert a number of packed characters to the number of cells (with - * truncation). - */ -void addr2cell(void) -{ - #if PAWN_CELL_SIZE==16 - stgwrite("\tshr.c.pri 1\n"); - #elif PAWN_CELL_SIZE==32 - stgwrite("\tshr.c.pri 2\n"); - #elif PAWN_CELL_SIZE==64 - stgwrite("\tshr.c.pri 3\n"); - #else - #error Unsupported cell size - #endif - code_idx+=opcodes(1)+opargs(1); -} - -/* Convert from character index to byte address. This routine does - * nothing if a character has the size of a byte. - */ -void char2addr(void) -{ - #if sCHARBITS==16 - stgwrite("\tshl.c.pri 1\n"); - code_idx+=opcodes(1)+opargs(1); - #endif -} - -/* Align PRI (which should hold a character index) to an address. - * The first character in a "pack" occupies the highest bits of - * the cell. This is at the lower memory address on Big Endian - * computers and on the higher address on Little Endian computers. - * The ALIGN.pri/alt instructions must solve this machine dependence; - * that is, on Big Endian computers, ALIGN.pri/alt shuold do nothing - * and on Little Endian computers they should toggle the address. - * - * NOTE: For Source Pawn, this is fliped. It will do nothing on Little-Endian. - */ -void charalign(void) -{ -#if 0 /* TEMPORARILY DISABLED BECAUSE WE DON'T USE BIG ENDIAN */ - stgwrite("\talign.pri "); - outval(sCHARBITS/8,TRUE); - code_idx+=opcodes(1)+opargs(1); -#endif -} - -/* - * Add a constant to the primary register. - */ -void addconst(cell value) -{ - if (value!=0) { - stgwrite("\tadd.c "); - outval(value,TRUE); - code_idx+=opcodes(1)+opargs(1); - } /* if */ -} - -/* - * signed multiply of primary and secundairy registers (result in primary) - */ -void os_mult(void) -{ - stgwrite("\tsmul\n"); - code_idx+=opcodes(1); -} - -/* - * signed divide of alternate register by primary register (quotient in - * primary; remainder in alternate) - */ -void os_div(void) -{ - stgwrite("\tsdiv.alt\n"); - code_idx+=opcodes(1); -} - -/* - * modulus of (alternate % primary), result in primary (signed) - */ -void os_mod(void) -{ - stgwrite("\tsdiv.alt\n"); - stgwrite("\tmove.pri\n"); /* move ALT to PRI */ - code_idx+=opcodes(2); -} - -/* - * Add primary and alternate registers (result in primary). - */ -void ob_add(void) -{ - stgwrite("\tadd\n"); - code_idx+=opcodes(1); -} - -/* - * subtract primary register from alternate register (result in primary) - */ -void ob_sub(void) -{ - stgwrite("\tsub.alt\n"); - code_idx+=opcodes(1); -} - -/* - * arithmic shift left alternate register the number of bits - * given in the primary register (result in primary). - * There is no need for a "logical shift left" routine, since - * logical shift left is identical to arithmic shift left. - */ -void ob_sal(void) -{ - stgwrite("\txchg\n"); - stgwrite("\tshl\n"); - code_idx+=opcodes(2); -} - -/* - * arithmic shift right alternate register the number of bits - * given in the primary register (result in primary). - */ -void os_sar(void) -{ - stgwrite("\txchg\n"); - stgwrite("\tsshr\n"); - code_idx+=opcodes(2); -} - -/* - * logical (unsigned) shift right of the alternate register by the - * number of bits given in the primary register (result in primary). - */ -void ou_sar(void) -{ - stgwrite("\txchg\n"); - stgwrite("\tshr\n"); - code_idx+=opcodes(2); -} - -/* - * inclusive "or" of primary and alternate registers (result in primary) - */ -void ob_or(void) -{ - stgwrite("\tor\n"); - code_idx+=opcodes(1); -} - -/* - * "exclusive or" of primary and alternate registers (result in primary) - */ -void ob_xor(void) -{ - stgwrite("\txor\n"); - code_idx+=opcodes(1); -} - -/* - * "and" of primary and secundairy registers (result in primary) - */ -void ob_and(void) -{ - stgwrite("\tand\n"); - code_idx+=opcodes(1); -} - -/* - * test ALT==PRI; result in primary register (1 or 0). - */ -void ob_eq(void) -{ - stgwrite("\teq\n"); - code_idx+=opcodes(1); -} - -/* - * test ALT!=PRI - */ -void ob_ne(void) -{ - stgwrite("\tneq\n"); - code_idx+=opcodes(1); -} - -/* The abstract machine defines the relational instructions so that PRI is - * on the left side and ALT on the right side of the operator. For example, - * SLESS sets PRI to either 1 or 0 depending on whether the expression - * "PRI < ALT" is true. - * - * The compiler generates comparisons with ALT on the left side of the - * relational operator and PRI on the right side. The XCHG instruction - * prefixing the relational operators resets this. We leave it to the - * peephole optimizer to choose more compact instructions where possible. - */ - -/* Relational operator prefix for chained relational expressions. The - * "suffix" code restores the stack. - * For chained relational operators, the goal is to keep the comparison - * result "so far" in PRI and the value of the most recent operand in - * ALT, ready for a next comparison. - * The "prefix" instruction pushed the comparison result (PRI) onto the - * stack and moves the value of ALT into PRI. If there is a next comparison, - * PRI can now serve as the "left" operand of the relational operator. - */ -void relop_prefix(void) -{ - stgwrite("\tpush.pri\n"); - stgwrite("\tmove.pri\n"); - code_idx+=opcodes(2); -} - -void relop_suffix(void) -{ - stgwrite("\tswap.alt\n"); - stgwrite("\tand\n"); - stgwrite("\tpop.alt\n"); - code_idx+=opcodes(3); -} - -/* - * test ALTPRI (signed) - */ -void os_gt(void) -{ - stgwrite("\txchg\n"); - stgwrite("\tsgrtr\n"); - code_idx+=opcodes(2); -} - -/* - * test ALT>=PRI (signed) - */ -void os_ge(void) -{ - stgwrite("\txchg\n"); - stgwrite("\tsgeq\n"); - code_idx+=opcodes(2); -} - -/* - * logical negation of primary register - */ -void lneg(void) -{ - stgwrite("\tnot\n"); - code_idx+=opcodes(1); -} - -/* - * two's complement primary register - */ -void neg(void) -{ - stgwrite("\tneg\n"); - code_idx+=opcodes(1); -} - -/* - * one's complement of primary register - */ -void invert(void) -{ - stgwrite("\tinvert\n"); - code_idx+=opcodes(1); -} - -/* - * nop - */ -void nooperation(void) -{ - stgwrite("\tnop\n"); - code_idx+=opcodes(1); -} - -void inc_pri() -{ - stgwrite("\tinc.pri\n"); - code_idx+=opcodes(1); -} - -void dec_pri() -{ - stgwrite("\tdec.pri\n"); - code_idx+=opcodes(1); -} - -/* increment symbol - */ -void inc(value *lval) -{ - symbol *sym; - - sym=lval->sym; - if (lval->ident==iARRAYCELL) { - /* indirect increment, address already in PRI */ - stgwrite("\tinc.i\n"); - code_idx+=opcodes(1); - } else if (lval->ident==iARRAYCHAR) { - /* indirect increment of single character, address already in PRI */ - stgwrite("\tpush.pri\n"); - stgwrite("\tpush.alt\n"); - stgwrite("\tmove.alt\n"); /* copy address */ - stgwrite("\tlodb.i "); /* read from PRI into PRI */ - outval(sCHARBITS/8,TRUE); /* read one or two bytes */ - stgwrite("\tinc.pri\n"); - stgwrite("\tstrb.i "); /* write PRI to ALT */ - outval(sCHARBITS/8,TRUE); /* write one or two bytes */ - stgwrite("\tpop.alt\n"); - stgwrite("\tpop.pri\n"); - code_idx+=opcodes(8)+opargs(2); - } else if (lval->ident==iREFERENCE) { - assert(sym!=NULL); - stgwrite("\tpush.pri\n"); - /* load dereferenced value */ - assert(sym->vclass==sLOCAL); /* global references don't exist in Pawn */ - if (sym->vclass==sLOCAL) - stgwrite("\tlref.s.pri "); - else - stgwrite("\tlref.pri "); - outval(sym->addr,TRUE); - /* increment */ - stgwrite("\tinc.pri\n"); - /* store dereferenced value */ - if (sym->vclass==sLOCAL) - stgwrite("\tsref.s.pri "); - else - stgwrite("\tsref.pri "); - outval(sym->addr,TRUE); - stgwrite("\tpop.pri\n"); - code_idx+=opcodes(5)+opargs(2); - } else { - /* local or global variable */ - assert(sym!=NULL); - if (sym->vclass==sLOCAL) - stgwrite("\tinc.s "); - else - stgwrite("\tinc "); - outval(sym->addr,TRUE); - code_idx+=opcodes(1)+opargs(1); - } /* if */ -} - -/* decrement symbol - * - * in case of an integer pointer, the symbol must be incremented by 2. - */ -void dec(value *lval) -{ - symbol *sym; - - sym=lval->sym; - if (lval->ident==iARRAYCELL) { - /* indirect decrement, address already in PRI */ - stgwrite("\tdec.i\n"); - code_idx+=opcodes(1); - } else if (lval->ident==iARRAYCHAR) { - /* indirect decrement of single character, address already in PRI */ - stgwrite("\tpush.pri\n"); - stgwrite("\tpush.alt\n"); - stgwrite("\tmove.alt\n"); /* copy address */ - stgwrite("\tlodb.i "); /* read from PRI into PRI */ - outval(sCHARBITS/8,TRUE); /* read one or two bytes */ - stgwrite("\tdec.pri\n"); - stgwrite("\tstrb.i "); /* write PRI to ALT */ - outval(sCHARBITS/8,TRUE); /* write one or two bytes */ - stgwrite("\tpop.alt\n"); - stgwrite("\tpop.pri\n"); - code_idx+=opcodes(8)+opargs(2); - } else if (lval->ident==iREFERENCE) { - assert(sym!=NULL); - stgwrite("\tpush.pri\n"); - /* load dereferenced value */ - assert(sym->vclass==sLOCAL); /* global references don't exist in Pawn */ - if (sym->vclass==sLOCAL) - stgwrite("\tlref.s.pri "); - else - stgwrite("\tlref.pri "); - outval(sym->addr,TRUE); - /* decrement */ - stgwrite("\tdec.pri\n"); - /* store dereferenced value */ - if (sym->vclass==sLOCAL) - stgwrite("\tsref.s.pri "); - else - stgwrite("\tsref.pri "); - outval(sym->addr,TRUE); - stgwrite("\tpop.pri\n"); - code_idx+=opcodes(5)+opargs(2); - } else { - /* local or global variable */ - assert(sym!=NULL); - if (sym->vclass==sLOCAL) - stgwrite("\tdec.s "); - else - stgwrite("\tdec "); - outval(sym->addr,TRUE); - code_idx+=opcodes(1)+opargs(1); - } /* if */ -} - -/* - * Jumps to "label" if PRI != 0 - */ -void jmp_ne0(int number) -{ - stgwrite("\tjnz "); - outval(number,TRUE); - code_idx+=opcodes(1)+opargs(1); -} - -/* - * Jumps to "label" if PRI == 0 - */ -void jmp_eq0(int number) -{ - stgwrite("\tjzer "); - outval(number,TRUE); - code_idx+=opcodes(1)+opargs(1); -} - -/* write a value in hexadecimal; optionally adds a newline */ -void outval(cell val,int newline) -{ - stgwrite(itoh(val)); - if (newline) - stgwrite("\n"); -} - -void invoke_getter(methodmap_method_t *method) -{ - if (!method->getter) { - error(149, method->name); - return; - } - - // push.c 1 - // sysreq.c N 1 - // stack 8 - pushreg(sPRI); - pushval(1); - ffcall(method->getter, NULL, 1); - - if (sc_status != statSKIP) - markusage(method->getter, uREAD); -} - -void invoke_setter(methodmap_method_t *method, int save) -{ - if (!method->setter) { - error(152, method->name); - return; - } - - if (save) - pushreg(sPRI); - pushreg(sPRI); - pushreg(sALT); - pushval(2); - ffcall(method->setter, NULL, 2); - if (save) - popreg(sPRI); - - if (sc_status != statSKIP) - markusage(method->setter, uREAD); -} diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp deleted file mode 100644 index 0c8d1528..00000000 --- a/sourcepawn/compiler/sc5-in.scp +++ /dev/null @@ -1,510 +0,0 @@ -/* Pawn compiler - Error message strings (plain and compressed formats) - * - * Copyright (c) ITB CompuPhase, 2000-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ - -int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]); - -#ifndef SCPACK -# define SCPACK -# define SCPACK_PUSH -#endif - -#define SCPACK_TABLE errstr_table -/*-*SCPACK start of pair table, do not change or remove this line */ -unsigned char errstr_table [][2] = { - {101,32}, {116,32}, {111,110}, {115,32}, {100,32}, {105,110}, {97,114}, {116,105}, {101,114}, {37,115}, {110,111}, {97,110}, {114,101}, {135,130}, {97,108}, {101,110}, - {117,110}, {111,114}, {34,137}, {146,34}, {121,32}, {138,129}, {115,105}, {101,132}, {115,116}, {97,116}, {100,101}, {109,143}, {116,104}, {32,147}, {41,10}, {109,98}, - {117,115}, {114,97}, {144,99}, {145,32}, {98,108}, {162,141}, {102,165}, {101,120}, {97,32}, {116,121}, {169,112}, {99,139}, {118,142}, {111,108}, {171,149}, {115,121}, - {115,10}, {175,159}, {136,32}, {134,161}, {177,173}, {103,32}, {116,111}, {115,150}, {103,117}, {105,132}, {184,155}, {134,186}, {101,131}, {105,131}, {160,129}, {44,32}, - {97,164}, {109,190}, {102,133}, {101,10}, {172,185}, {99,104}, {99,116}, {166,32}, {133,196}, {104,97}, {111,102}, {117,108}, {98,128}, {167,112}, {97,141}, {179,148}, - {110,32}, {109,97}, {101,100}, {99,111}, {99,130}, {37,131}, {118,134}, {180,157}, {202,32}, {105,192}, {214,217}, {109,101}, {111,112}, {137,10}, {130,32}, {99,108}, - {118,128}, {170,128}, {187,129}, {154,194}, {102,105}, {119,105}, {108,128}, {97,131}, {220,136}, {116,97}, {100,105}, {97,115}, {157,10}, {109,153}, {152,153}, {218,128}, - {139,132}, {215,158}, {133,32}, {110,97}, {201,224}, {40,241}, {116,117}, {150,122}, {156,128}, {212,152}, {34,32}, {138,32}, {139,32}, {142,32}, {156,32} -}; -/*-*SCPACK end of pair table, do not change or remove this line */ - -static const char *errmsg[] = { -#ifdef SCPACK -/*001*/ "expected token: \"%s\", but found \"%s\"\n", -/*002*/ "only a single statement (or expression) can follow each \"case\"\n", -/*003*/ "declaration of a local variable must appear in a compound block\n", -/*004*/ "function \"%s\" is not implemented\n", -/*005*/ "function may not have arguments\n", -/*006*/ "must be assigned to an array\n", -/*007*/ "operator cannot be redefined\n", -/*008*/ "must be a constant expression; assumed zero\n", -/*009*/ "invalid array size (negative, zero or out of bounds)\n", -/*010*/ "invalid function or declaration\n", -/*011*/ "invalid outside functions\n", -/*012*/ "invalid function call, not a valid address\n", -/*013*/ "no entry point (no public functions)\n", -/*014*/ "invalid statement; not in switch\n", -/*015*/ "\"default\" case must be the last case in switch statement\n", -/*016*/ "multiple defaults in \"switch\"\n", -/*017*/ "undefined symbol \"%s\"\n", -/*018*/ "initialization data exceeds declared size\n", -/*019*/ "not a label: \"%s\"\n", -/*020*/ "invalid symbol name \"%s\"\n", -/*021*/ "symbol already defined: \"%s\"\n", -/*022*/ "must be lvalue (non-constant)\n", -/*023*/ "array assignment must be simple assignment\n", -/*024*/ "\"break\" or \"continue\" is out of context\n", -/*025*/ "function heading differs from prototype\n", -/*026*/ "no matching \"#if...\"\n", -/*027*/ "invalid character constant\n", -/*028*/ "invalid subscript (not an array or too many subscripts): \"%s\"\n", -/*029*/ "invalid expression, assumed zero\n", -/*030*/ "compound statement not closed at the end of file (started at line %d)\n", -/*031*/ "unknown directive\n", -/*032*/ "array index out of bounds (variable \"%s\")\n", -/*033*/ "array must be indexed (variable \"%s\")\n", -/*034*/ "argument does not have a default value (argument %d)\n", -/*035*/ "argument type mismatch (argument %d)\n", -/*036*/ "empty statement\n", -/*037*/ "invalid string (possibly non-terminated string)\n", -/*038*/ "extra characters on line\n", -/*039*/ "constant symbol has no size\n", -/*040*/ "duplicate \"case\" label (value %d)\n", -/*041*/ "invalid ellipsis, array size is not known\n", -/*042*/ "invalid combination of class specifiers\n", -/*043*/ "character constant exceeds range for packed string\n", -/*044*/ "positional parameters must precede all named parameters\n", -/*045*/ "too many function arguments\n", -/*046*/ "unknown array size (variable \"%s\")\n", -/*047*/ "array sizes do not match, or destination array is too small\n", -/*048*/ "array (s do not match\n", -/*049*/ "invalid line continuation\n", -/*050*/ "invalid range\n", -/*051*/ "invalid subscript, use \"[ ]\" operators on major dimensions\n", -/*052*/ "multi-dimensional arrays must be fully initialized\n", -/*053*/ "exceeding maximum number of dimensions\n", -/*054*/ "unmatched closing brace (\"}\")\n", -/*055*/ "start of function body without function header\n", -/*056*/ "arrays, local variables and function arguments cannot be public (variable \"%s\")\n", -/*057*/ "unfinished expression before compiler directive\n", -/*058*/ "duplicate argument; same argument is passed twice\n", -/*059*/ "function argument may not have a default value (variable \"%s\")\n", -/*060*/ "multiple \"#else\" directives between \"#if ... #endif\"\n", -/*061*/ "\"#elseif\" directive follows an \"#else\" directive\n", -/*062*/ "number of operands does not fit the operator\n", -/*063*/ "function result tag of operator \"%s\" must be \"%s\"\n", -/*064*/ "cannot change predefined operators\n", -/*065*/ "function argument may only have a single tag (argument %d)\n", -/*066*/ "function argument may not be a reference argument or an array (argument \"%s\")\n", -/*067*/ "variable cannot be both a reference and an array (variable \"%s\")\n", -/*068*/ "invalid rational number precision in #pragma\n", -/*069*/ "rational number format already defined\n", -/*070*/ "rational number support was not enabled\n", -/*071*/ "user-defined operator must be declared before use (function \"%s\")\n", -/*072*/ "\"sizeof\" operator is invalid on \"function\" symbols\n", -/*073*/ "function argument must be an array (argument \"%s\")\n", -/*074*/ "#define pattern must start with an alphabetic character\n", -/*075*/ "input line too long (after substitutions)\n", -/*076*/ "syntax error in the expression, or invalid function call\n", -/*077*/ "malformed UTF-8 encoding, or corrupted file: %s\n", -/*078*/ "function uses both \"return\" and \"return \"\n", -/*079*/ "inconsistent return types (array & non-array)\n", -/*080*/ "unknown symbol, or not a constant symbol (symbol \"%s\")\n", -/*081*/ "cannot take a tag as a default value for an indexed array parameter (symbol \"%s\")\n", -/*082*/ "user-defined operators and native functions may not have states\n", -/*083*/ "a function or variable may only belong to a single automaton (symbol \"%s\")\n", -/*084*/ "state conflict: one of the states is already assigned to another implementation (symbol \"%s\")\n", -/*085*/ "no states are defined for symbol \"%s\"\n", -/*086*/ "unknown automaton \"%s\"\n", -/*087*/ "unknown state \"%s\" for automaton \"%s\"\n", -/*088*/ "public variables and local variables may not have states (symbol \"%s\")\n", -/*089*/ "state variables may not be initialized (symbol \"%s\")\n", -/*090*/ "public functions may not return arrays (symbol \"%s\")\n", -/*091*/ "ambiguous constant; tag override is required (symbol \"%s\")\n", -/*092*/ "number of arguments does not match definition\n", -/*093*/ "expected tag name identifier\n", -/*094*/ "function enumeration requires unique tag\n", -/*095*/ "cannot have required parameters after optional parameters\n", -/*096*/ "could not find member \"%s\" in struct \"%s\"\n", -/*097*/ "symbol \"%s\" does not have a matching type\n", -/*098*/ "type \"%s\" should be \"%s\" in new-style declarations\n", -/*099*/ "%s should not have an explicit return type\n", -/*100*/ "function prototypes do not match\n", -/*101*/ "specify either all dimensions or only the last dimension\n", -/*102*/ "cannot find %s %s\n", -/*103*/ "%s was already defined on this %s\n", -/*104*/ "cannot find any methods for %s\n", -/*105*/ "cannot find method or property %s.%s\n", -/*106*/ "cannot call methods on an array\n", -/*107*/ "cannot call methods on a function\n", -/*108*/ "method must have a first argument compatible with the %s type (%s)\n", -/*109*/ "%s name must start with an uppercase letter\n", -/*110*/ "%s has already been defined (previously seen as %s)\n", -/*111*/ "expected identifier - did you forget a type?\n", -/*112*/ "constructor function must return tag %s\n", -/*113*/ "constructor for \"%s\" already exists\n", -/*114*/ "missing type, or %s must have the same name as %s \"%s\"\n", -/*115*/ "cannot use delete, %s %s has no destructor\n", -/*116*/ "no methodmap or class was found for %s\n", -/*117*/ "no destructor was found for %s %s\n", -/*118*/ "destructors must be native functions\n", -/*119*/ "destructors cannot have extra arguments\n", -/*120*/ "methodmap and class signatures must use new-style type declarations\n", -/*121*/ "cannot specify array dimensions on both type and name\n", -/*122*/ "expected type expression\n", -/*123*/ "fully-qualified name \"%s\" is too long, would be truncated to \"%s\"\n", -/*124*/ "unexpected token, expected method or property\n", -/*125*/ "expected \"native\", \"get\", or \"set\"\n", -/*126*/ "%s for %s already exists\n", -/*127*/ "property getters cannot accept extra arguments\n", -/*128*/ "%s must have the same return type as property %s (%s)\n", -/*129*/ "cannot mix methodmaps and classes with inheritance\n", -/*130*/ "cannot coerce functions to values\n", -/*131*/ "cannot coerce object type %s to non-object type %s\n", -/*132*/ "cannot coerce non-object type %s to object type %s\n", -/*133*/ "cannot coerce unrelated object types %s and %s\n", -/*134*/ "type mismatch (%s and %s)\n", -/*135*/ "cannot use an object in a multi-tag selector\n", -/*136*/ "arrays are not supported as return types\n", -/*137*/ "cannot mix reference and array types\n", -/*138*/ "const was specified twice\n", -/*139*/ "could not find type \"%s\"\n", -/*140*/ "new-style array types cannot specify dimension sizes as part of their type\n", -/*141*/ "natives, forwards, and public functions cannot return arrays\n", -/*142*/ "invalid type declaration\n", -/*143*/ "new-style declarations should not have \"new\"\n", -/*144*/ "void cannot be used as a variable type\n", -/*145*/ "invalid type expression\n", -/*146*/ "#pragma newdecls must be required or optional\n", -/*147*/ "new-style declarations are required\n", -/*148*/ "cannot assign null to a non-nullable type\n", -/*149*/ "no getter found for property %s\n", -/*150*/ "setter must take exactly one extra argument with type %s\n", -/*151*/ "setter must return void\n", -/*152*/ "no setter found for property %s\n", -/*153*/ "cannot use non-public functions as callbacks\n", -/*154*/ "cannot assign INVALID_FUNCTION to a non-function type\n", -/*155*/ "expected newline, but found '%s'\n", -/*156*/ "unused156\n", -/*157*/ "'%s' is a reserved keyword\n", -/*158*/ "multi-tags are no longer supported\n", -/*159*/ "brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x')\n", -/*160*/ "brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given\n", -/*161*/ "brackets after variable name indicate a fixed-size array, but a dynamic size was given - did you mean to use 'new %s[size]' syntax?\n", -/*162*/ "cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name?\n", -/*163*/ "indeterminate array size in \"sizeof\" expression (symbol \"%s\")\n", -/*164*/ "allocated array type '%s' doesn't match original type '%s'\n", -/*165*/ "cannot create dynamic arrays in static scope - did you mean to create a fixed-length array with brackets after the variable name?\n", -/*166*/ "cannot use 'this' outside of a methodmap method or property\n", -/*167*/ "cannot use delete, %s do not have destructors\n", -/*168*/ "re-tagging enums is no longer supported\n", -/*169*/ "cannot tag an enum as implicit-int\n", -/*170*/ "creating new object '%s' requires using 'new' before its constructor\n", -/*171*/ "cannot use 'new' with non-object-like methodmap '%s'\n", -/*172*/ "methodmap '%s' does not have a constructor\n", -/*173*/ "'%s' is a newly reserved keyword that may be used in the future; use a different name as an identifier\n", -/*174*/ "symbol '%s' is a type and cannot be used as a value\n", -/*175*/ "constructors cannot be static\n", -/*176*/ "non-static method or property '%s' must be called with a value of type '%s'\n", -/*177*/ "static method '%s' must be invoked via its type (try '%s.%s')\n", -/*178*/ "cannot coerce %s[] to %s[]; storage classes differ\n", -/*179*/ "cannot assign %s[] to %s[], storage classes differ\n", -#else - "\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012", - "\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012", - "\232\337\206\316 \330\250loc\375\357\301appe\206 \362\250\323mpo\220\204\244ock\012", - "\246\235 \275\225imple\233t\322\012", - "\307\321\224\225\364\273t\260", - "\301\314a\267gn\227\266 \374\263y\012", - "\350\231\243\256\314\214\343\322\012", - "\301\314\250\371\213\201\315\214\267\202; \353sum\227z\210o\012", - "\310\317\367\200(nega\207ve\277z\210o \243ou\201\330bo\220ds\236", - "\310\307\243\232\337\206\316\012", - "\310out\226d\200\246\260", - "\310\307c\216l\277\225\250\304add\214s\260", - "\373\217tr\224po\205\201(\373pu\244ic \246s\236", - "\310\356e\233t; \225\362s\345t\305\012", - "\042\232fa\313t\372c\353\200\301\314\370l\353\201c\353\200\362s\345t\305 \356e\233t\012", - "m\313\207p\346\232fa\313t\203\362\042s\345t\305\042\012", - "\220\343\227\327\012", - "\205i\207\216iz\316 d\231\250\247ce\322\203\232\337\206\227\367\303", - "\225\250label:\354", - "\310\264 \363m\200\223\012", - "\264 \216\214ad\224\343\322:\354", - "\301\314l\254u\200(n\202-\371\213t\236", - "\317a\267gn\233\201\301\314\226mp\346a\267gn\233t\012", - "\042b\214ak\372\243\042\324t\205ue\372\275ou\201\330\324t\247t\012", - "\307head\205\265\352ff\210\203from pro\266\252\303", - "\373\355\305\205\265\042#if...\042\012", - "\310\305\206a\306\262\371\213t\012", - "\310subscrip\201(\225\374\317\243\266o m\213\224subscripts):\354", - "\310\315\214\267\202\277\353sum\227z\210o\012", - "\323mpo\220\204\356e\233\201\225\337os\227a\201\370\217\204\330\344\346(\230\206t\227a\201l\205\200%d\236", - "\220k\212w\320\352\214c\207v\303", - "\317\205\232x ou\201\330bo\220d\203(\357\223\236", - "\317\301\314\205\232x\227(\357\223\236", - "\342do\274\225\364\250\232fa\313\201\254u\200(\342%d\236", - "\342\341mis\355\305 (\342%d\236", - "empt\224\356e\233t\012", - "\310\230r\205\265(po\267\244\224n\202-t\210m\205\231\227\230r\205g\236", - "\247t\241 \305\206a\306\210\203\336l\205\303", - "\371\213\201\264 \311\203\373\367\303", - "duplic\231\200\042c\353e\372label (\254u\200%d\236", - "\310ellip\226s\277\317\367\200\275\225k\212wn\012", - "\310\323\237\205\316 \330\337\353\203speci\344\210\260", - "\305\206a\306\262\371\213\201\247ce\322\203r\213g\200f\243pack\227\230r\205g\012", - "po\226\215\375p\206a\333t\210\203\301p\214c\322\200\216l \363m\227p\206a\333t\210\260", - "\266o m\213\224\307\273t\260", - "\220k\212w\320\317\367\200(\357\223\236", - "\317\367\274do \225\355\305\277\243\232\230\205\316 \317\275\266o sm\216l\012", - "\317(\203do \225\355\305\012", - "\310l\205\200\324t\205u\316\012", - "\310r\213g\303", - "\310subscript\277\240\200\042[ ]\372\350\231\221\203\336\321j\243\352\233\226\202\260", - "m\313\207-\352\233\226\202\375\263y\203\301\314f\313l\224\205i\207\216iz\322\012", - "\247ce\322\205\265\321ximum nu\237\262\330\352\233\226\202\260", - "\220\355\305\227\337os\205\265b\241c\200(\042}\042\236", - "\230\206\201\330\307bod\224\345\234ou\201\307head\210\012", - "\263ys\277loc\375\332\274\360\307\273t\203\256\314pu\244ic (\357\223\236", - "\220\302ish\227\315\214\267\336bef\221\200\323mpil\262\352\214c\207v\303", - "duplic\231\200\273t; sam\200\342\275p\353s\227t\345c\303", - "\307\342\321\224\225\364\250\232fa\313\201\254u\200(\357\223\236", - "m\313\207p\346\042#else\372\352\214c\207v\274betwe\217 \042#if ... #\217\352f\042\012", - "\042#elseif\372\352\214c\207\340f\255low\203\374\042#else\372\352\214c\207v\303", - "nu\237\262\330\350\213d\203do\274\225\344\201\370\350\231\221\012", - "\307\214s\313\201\351\265\330\350\231\221\235 \301\314\223\012", - "\256\305\213g\200p\214\343\227\350\231\221\260", - "\307\342\321\224\202l\224\364\250s\205g\346\351\265(\342%d\236", - "\307\342\321\224\225\314\250\214f\210\217c\200\342\243\374\317(\342\223\236", - "\357\256\314bo\376\250\214f\210\217c\200\360\374\317(\357\223\236", - "\310\241\215\375nu\237\262p\214ci\226\336\362#p\241g\321\012", - "\241\215\375nu\237\262f\221\321\201\216\214ad\224\343\322\012", - "\241\215\375nu\237\262supp\221\201w\347\225\217\300\322\012", - "\240\210-\343\227\350\231\243\301\314\232\337\206\227bef\221\200\240\200(\246\235\236", - "\042\367e\312\372\350\231\243\275\310\336\042\246\372\264\260", - "\307\342\301\314\374\317(\342\223\236", - "#\343\200p\231t\210\320\301\230\206\201\345\376\374\216p\311be\207c \305\206a\306\210\012", - "\205pu\201l\205\200\266o l\202\265(aft\262subs\207\366\215s\236", - "\257n\351x \210r\243\362\370\315\214\267\202\277\243\310\307c\216l\012", - "m\216f\221m\227UTF-8 \217\323d\205g\277\243c\221rupt\227\344le: \335", - "\307\240\274bo\376\042\214\366rn\372\360\042\214\366r\320<\254ue>\042\012", - "\205\324\226\230\217\201\214\366r\320\252\274(\317& n\202-\263y\236", - "\220k\212w\320\264\277\243\225\250\371\213\201\264 \365", - "\256\351k\200\250\351\265\347\250\232fa\313\201\254u\200f\243\374\205\232x\227\317p\206a\333t\262\365", - "\240\210-\343\227\350\231\221\203\360\363\207\340\246\203\321\224\225\364\356e\260", - "\250\307\243\357\321\224\202l\224bel\202\265\266 \250s\205g\346au\266\355\336\365", - "\356\200\324fli\306: \202\200\330\370\356\274\275\216\214ad\224a\267gn\227\266 a\212\234\262imple\233t\316 \365", - "\373\356\274\206\200\343\227f\243\327\012", - "\220k\212w\320au\266\355\202\354", - "\220k\212w\320\356\200\223 f\243au\266\355\202\354", - "pu\244ic \332\274\360loc\375\332\274\321\224\225\364\356\274\365", - "\356\200\332\274\321\224\225\314\205i\207\216iz\227\365", - "pu\244ic \246\203\321\224\225\214\366r\320\263y\203\365", - "a\237i\270ou\203\371\213t; \351\265ov\210rid\200\275\214qui\214\204\365", - "nu\237\262\330\273t\203do\274\225\355\305 \343i\215\012", - "\315e\306\227\351\265\363m\200id\217\207\344\210\012", - "\307\217um\210\316 \214qui\214\203\220iqu\200\351g\012", - "\256\364\214qui\214\204p\206a\333t\210\203aft\262\334\215\375p\206a\333t\210\260", - "\323\313\204\225\302\204\333\237\210\235 \362\230ruc\201\223\012", - "\327 do\274\225\364\250\355\305\205\265\252\303", - "\341\223 sho\313\204\314\223 \362new-\230y\346\232\337\206\316\260", - "\325sho\313\204\225\364\374\315lici\201\214\366r\320\252\303", - "\307pro\266\252\274do \225\355\305\012", - "specif\224ei\234\262\216l \352\233\226\202\203\243\202l\224\370l\353\201\352\233\226\202\012", - "\256\302\204\325\335", - "\325w\347\216\214ad\224\343\227\336\234\275\335", - "\256\302\204\213\224\333\234od\203f\243\335", - "\256\302\204\333\234o\204\243pr\350t\224\211.\335", - "\256c\216l \333\234od\203\336\374\263y\012", - "\256c\216l \333\234od\203\336\250\246\012", - "\333\234o\204\301\364\250\344rs\201\342\323mpa\207\244\200\345\376\370\325\341(\211\236", - "\325\363m\200\301\230\206\201\345\376\374upp\210c\353\200lett\210\012", - "\325\311\203\216\214ad\224be\217 \343\227(p\214vio\240l\224se\217 \347\211\236", - "\315e\306\227id\217\207\344\262- d\271you f\221ge\201\250\252e?\012", - "\371ru\306\243\307\301\214\366r\320\351\265\335", - "\256\343\200\371ru\306\243f\221\235; \216\214ad\224\247i\230\203\347\250\335", - "miss\205\265\252e\277\243\325\301\364\370sam\200\363m\200\347\325\223\012", - "\256\240\200\232lete\277\325\325\311\203\373\232\230ru\306\221\012", - "\373\333\234od\321p \243\337\353\203w\347fo\220\204f\243\335", - "\373\232\230ru\306\243w\347fo\220\204f\243\325\335", - "\232\230ru\306\221\203\301\314\363\207\340\246\260", - "\232\230ru\306\221\203\256\364\247t\241 \273t\260", - "\333\234od\321p \360\337\353\203\226gn\231u\214\203\301\240\200new-\230y\346\341\232\337\206\316\260", - "\256specif\224\317\352\233\226\202\203\336bo\376\341\360\363m\303", - "\315e\306\227\341\315\214\267\202\012", - "f\313ly-qu\216i\344\227\363m\200\223 \275\266o l\202g\277wo\313\204\314tr\242\231\227\266\354", - "\220\315e\306\227\266k\217\277\315e\306\227\333\234o\204\243pr\350\251\012", - "\315e\306\227\042\363\207ve\042\277\042get\042\277\243\042set\042\012", - "\325f\243\325\216\214ad\224\247i\230\260", - "pr\350t\224gett\210\203\256accep\201\247t\241 \273t\260", - "\325\301\364\370sam\200\214\366r\320\341\347pr\350t\224\325(\211\236", - "\256mix \333\234od\321p\203\360\337\353s\274\345\376\205h\210it\213c\303", - "\256\323\210c\200\246\203\266 \254ue\260", - "\256\323\210c\200objec\201\341\325\266 n\202-objec\201\341\335", - "\256\323\210c\200n\202-objec\201\341\325\266 objec\201\341\335", - "\256\323\210c\200\220\214l\231\227objec\201\252\274\325\360\335", - "\341mis\355\305 (\325\360\211\236", - "\256\240\200\374objec\201\362\250m\313\207-\351\265sele\306\221\012", - "\263y\203\206\200\225supp\221t\227\347\214\366r\320\252e\260", - "\256mix \214f\210\217c\200\360\317\252e\260", - "\324s\201w\347speci\344\227t\345c\303", - "\323\313\204\225\302\204\341\223\012", - "new-\230y\346\317\252\274\256specif\224\352\233\226\336\367\274\347p\206\201\330\234eir \252\303", - "\363\207ves\277f\221w\206ds\277\360pu\244ic \246\203\256\214\366r\320\263y\260", - "\310\341\232\337\206\316\012", - "new-\230y\346\232\337\206\316\203sho\313\204\225\364\042new\042\012", - "vo\271\256\314\240\227\347\250\357\252\303", - "\310\341\315\214\267\202\012", - "#p\241gm\250new\232\337\203\301\314\214qui\214\204\243\334\215\216\012", - "new-\230y\346\232\337\206\316\203\206\200\214qui\214d\012", - "\256a\267g\320n\313l \266 \250n\202-n\313l\300\200\252\303", - "\373gett\262fo\220\204f\243pr\350t\224\335", - "sett\262\301\351k\200\247a\306l\224\202\200\247t\241 \342\345\376\341\335", - "sett\262\301\214\366r\320void\012", - "\373sett\262fo\220\204f\243pr\350t\224\335", - "\256\240\200n\202-pu\244ic \246\203\347c\216lback\260", - "\256a\267g\320INVALID_FUNCTION \266 \250n\202-\307\252\303", - "\315e\306\227newl\205e\277bu\201fo\220\204'\211'\012", - "\370'\213y' \341\275\225\216low\227\362new-\230y\346\363\207ve\260", - "'\211' \275\250\214s\210v\227keyw\221d\012" -#endif - }; - -static const char *fatalmsg[] = { -#ifdef SCPACK -/*180*/ "cannot read from file: \"%s\"\n", -/*181*/ "cannot write to file: \"%s\"\n", -/*182*/ "table overflow: \"%s\"\n", - /* table can be: loop table - * literal table - * staging buffer - * option table (response file) - * peephole optimizer table - */ -/*183*/ "insufficient memory\n", -/*184*/ "invalid assembler instruction \"%s\"\n", -/*185*/ "numeric overflow, exceeding capacity\n", -/*186*/ "compiled script exceeds the maximum memory size (%ld bytes)\n", -/*187*/ "too many error messages on one line\n", -/*188*/ "codepage mapping file not found\n", -/*189*/ "invalid path: \"%s\"\n", -/*190*/ "assertion failed: %s\n", -/*191*/ "user error: %s\n", -#else - "\256\214a\204from \344le:\354", - "\256writ\200\266 \344le:\354", - "t\300\200ov\210flow:\354", - "\205suf\344ci\217\201\333m\221y\012", - "\310\353se\237l\262\205\230ruc\215\354", - "num\210ic ov\210flow\277\247ce\322\205\265capaci\251\012", - "\323mpil\227scrip\201\247ce\322\203\370\321ximum \333m\221\224\367\200(%l\204bytes\236", - "\266o m\213\224\210r\243\333ssag\274\336\202\200l\205\303", - "\323\232pag\200\321pp\205\265\344\346\225fo\220d\012", - "\310p\231h:\354", - "\353s\210\215 fail\322: \335", - "\240\262\210r\221: \335" -#endif - }; - -static const char *warnmsg[] = { -#ifdef SCPACK -/*200*/ "symbol \"%s\" is truncated to %d characters\n", -/*201*/ "redefinition of constant/macro (symbol \"%s\")\n", -/*202*/ "number of arguments does not match definition\n", -/*203*/ "symbol is never used: \"%s\"\n", -/*204*/ "symbol is assigned a value that is never used: \"%s\"\n", -/*205*/ "redundant code: constant expression is zero\n", -/*206*/ "redundant test: constant expression is non-zero\n", -/*207*/ "unknown #pragma\n", -/*208*/ "function with tag result used before definition, forcing reparse\n", -/*209*/ "function \"%s\" should return a value\n", -/*210*/ "possible use of symbol before initialization: \"%s\"\n", -/*211*/ "possibly unintended assignment\n", -/*212*/ "possibly unintended bitwise operation\n", -/*213*/ "tag mismatch\n", -/*214*/ "possibly a \"const\" array argument was intended: \"%s\"\n", -/*215*/ "expression has no effect\n", -/*216*/ "nested comment\n", -/*217*/ "loose indentation\n", -/*218*/ "old style prototypes used with optional semicolumns\n", -/*219*/ "local variable \"%s\" shadows a variable at a preceding level\n", -/*220*/ "expression with tag override must appear between parentheses\n", -/*221*/ "label name \"%s\" shadows tag name\n", -/*222*/ "number of digits exceeds rational number precision\n", -/*223*/ "redundant \"sizeof\": argument size is always 1 (symbol \"%s\")\n", -/*224*/ "unused\n", -/*225*/ "unreachable code\n", -/*226*/ "a variable is assigned to itself (symbol \"%s\")\n", -/*227*/ "more initializers than enum fields\n", -/*228*/ "length of initializer exceeds size of the enum field\n", -/*229*/ "index tag mismatch (symbol \"%s\")\n", -/*230*/ "no implementation for state \"%s\" in function \"%s\", no fall-back\n", -/*231*/ "state specification on forward declaration is ignored\n", -/*232*/ "output file is written, but with compact encoding disabled\n", -/*233*/ "state variable \"%s\" shadows a global variable\n", -/*234*/ "symbol \"%s\" is marked as deprecated: %s\n", -/*235*/ "public function lacks forward declaration (symbol \"%s\")\n", -/*236*/ "unknown parameter in substitution (incorrect #define pattern)\n", -/*237*/ "coercing functions to and from primitives is unsupported and will be removed in the future\n", -/*238*/ "'%s:' is an illegal cast; use view_as<%s>(expression)\n", -/*239*/ "'%s' is an illegal tag; use %s as a type\n", -/*240*/ "'%s:' is an old-style tag operation; use view_as<%s>(expression) instead\n", -#else - "\327 \275tr\242\231\227\266 %\204\305\206a\306\210\260", - "\214\343i\215 \330\371\213t/\321cro \365", - "nu\237\262\330\273t\203do\274\225\355\305 \343i\215\012", - "\264 \275nev\262\240\322:\354", - "\264 \275a\267gn\227\250\254u\200\234a\201\275nev\262\240\322:\354", - "\214d\220d\213\201\323\232: \371\213\201\315\214\267\336\275z\210o\012", - "\214d\220d\213\201te\230: \371\213\201\315\214\267\336\275n\202-z\210o\012", - "\220k\212w\320#p\241g\321\012", - "\307\345\376\351\265\214s\313\201\240\227bef\221\200\343i\215\277f\221c\205\265\214p\206s\303", - "\246\235 sho\313\204\214\366r\320\250\254u\303", - "po\267\244\200\240\200\330\264 bef\221\200\205i\207\216iz\316:\354", - "po\267\244\224\220\205t\217d\227a\267gn\233t\012", - "po\267\244\224\220\205t\217d\227bit\345s\200\350\316\012", - "\351\265mis\355\305\012", - "po\267\244\224\250\042\371\372\317\342w\347\205t\217\232d:\354", - "\315\214\267\336\311\203\373effe\306\012", - "ne\230\227\323m\233t\012", - "loos\200\205d\217t\316\012", - "\255\204\230y\346pro\266\252\274\240\227\345\376\334\215\375semic\255umn\260", - "loc\375\357\223 s\311dow\203\250\357a\201\250p\214c\322\205\265level\012", - "\315\214\267\336\345\376\351\265ov\210rid\200\301appe\206 betwe\217 p\206\217\234ese\260", - "label \363m\200\223 s\311dow\203\351\265\363m\303", - "nu\237\262\330\352git\203\247ce\322\203\241\215\375nu\237\262p\214ci\226\202\012", - "\214d\220d\213\201\042\367e\312\042: \342\367\200\275\216way\2031 \365", - "\205\232t\210m\205\231\200\317\367\200\362\042\367e\312\372\315\214\267\336\365", - "\220\214a\305\300\200\323\232\012", - "\250\357\275a\267gn\227\266 itself \365", - "m\221\200\205i\207\216iz\210\203\234\374\217um \344eld\260", - "l\217g\376\330\205i\207\216iz\262\247ce\322\203\367\200\330\370\217um \344eld\012", - "\205\232x \351\265mis\355\305 \365", - "\373imple\233t\316 f\243\356\200\223 \362\246\235\277\373f\216l-back\012", - "\356\200speci\344c\316 \336f\221w\206\204\232\337\206\316 \275ig\212\214d\012", - "outpu\201\344\346\275writt\217\277bu\201\345\376\323mpac\201\217\323d\205\265\352s\300\322\012", - "\356\200\357\223 s\311dow\203\250glob\375\332\303", - "\327 \275m\206k\227\347\232p\214c\231\322: \335", - "pu\244ic \307lack\203f\221w\206\204\232\337\206\316 \365", - "\220k\212w\320p\206a\333t\262\362subs\207\366\215 (\205c\221\214c\201#\343\200p\231t\210n\236", - "\323\210c\205\265\246\203\266 \360from primi\207v\274\275\220supp\221t\227\360\345ll \314\214mov\227\362\370fu\366\214\012" -#endif - }; - -#ifdef SCPACK_PUSH -# undef SCPACK -#endif diff --git a/sourcepawn/compiler/sc5.cpp b/sourcepawn/compiler/sc5.cpp deleted file mode 100644 index 17d48618..00000000 --- a/sourcepawn/compiler/sc5.cpp +++ /dev/null @@ -1,243 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -/* Pawn compiler - Error message system - * In fact a very simple system, using only 'panic mode'. - * - * Copyright (c) ITB CompuPhase, 1997-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#if defined __WIN32__ || defined _WIN32 || defined __MSDOS__ - #include -#endif -#if defined LINUX || defined __GNUC__ - #include -#endif -#include -#include -#include /* ANSI standardized variable argument list functions */ -#include -#if defined FORTIFY - #include -#endif -#include "sc.h" - -#if defined _MSC_VER - #pragma warning(push) - #pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */ -#endif - -#include - -#if defined _MSC_VER - #pragma warning(pop) -#endif - -#define NUM_WARNINGS (sizeof warnmsg / sizeof warnmsg[0]) -static unsigned char warndisable[(NUM_WARNINGS + 7) / 8]; /* 8 flags in a char */ - -static int errflag; -static int errstart; /* line number at which the instruction started */ -static int sErrLine; /* forced line number for the error message */ - -/* error - * - * Outputs an error message (note: msg is passed optionally). - * If an error is found, the variable "errflag" is set and subsequent - * errors are ignored until lex() finds a semicolumn or a keyword - * (lex() resets "errflag" in that case). - * - * Global references: inpfname (reffered to only) - * fline (reffered to only) - * fcurrent (reffered to only) - * errflag (altered) - */ -int error(int number,...) -{ -static const char *prefix[3]={ "error", "fatal error", "warning" }; -static int lastline,errorcount; -static short lastfile; - const char *msg,*pre; - va_list argptr; - - // sErrLine is used to temporarily change the line number of reported errors. - // Pawn has an upstream bug where this is not reset on early-return, which - // can lead to broken line numbers in error messages. - int errline = sErrLine; - sErrLine = -1; - - bool is_warning = (number >= 200 && !sc_warnings_are_errors); - - /* errflag is reset on each semicolon. - * In a two-pass compiler, an error should not be reported twice. Therefore - * the error reporting is enabled only in the second pass (and only when - * actually producing output). Fatal errors may never be ignored. - */ - int not_fatal = (number < FIRST_FATAL_ERROR || number >= 200); - if (errflag && not_fatal) - return 0; - if (sc_status != statWRITE && not_fatal) { - if (!sc_err_status) - return 0; - } - - /* also check for disabled warnings */ - if (number>=200) { - int index=(number-200)/8; - int mask=1 << ((number-200)%8); - if ((warndisable[index] & mask)!=0) - return 0; - } /* if */ - - if (number0) - errstart=errline; - else - errline=fline; - assert(errstart<=errline); - va_start(argptr,number); - if (strlen(errfname)==0) { - int start= (errstart==errline) ? -1 : errstart; - if (pc_error(number,msg,inpfname,start,errline,argptr)) { - if (outf!=NULL) { - pc_closeasm(outf,TRUE); - outf=NULL; - } /* if */ - longjmp(errbuf,3); /* user abort */ - } /* if */ - } else { - FILE *fp=fopen(errfname,"a"); - if (fp!=NULL) { - if (errstart>=0 && errstart!=errline) - fprintf(fp,"%s(%d -- %d) : %s %03d: ",inpfname,errstart,errline,pre,number); - else - fprintf(fp,"%s(%d) : %s %03d: ",inpfname,errline,pre,number); - vfprintf(fp,msg,argptr); - fclose(fp); - } /* if */ - } /* if */ - va_end(argptr); - - if ((number>=FIRST_FATAL_ERROR && number<200) || errnum>25){ - if (strlen(errfname)==0) { - va_start(argptr,number); - pc_error(0,"\nCompilation aborted.",NULL,0,0,argptr); - va_end(argptr); - } /* if */ - if (outf!=NULL) { - pc_closeasm(outf,TRUE); - outf=NULL; - } /* if */ - longjmp(errbuf,2); /* fatal error, quit */ - } /* if */ - - /* check whether we are seeing many errors on the same line */ - if ((errstart<0 && lastline!=fline) || lastlinefline || fcurrent!=lastfile) - errorcount=0; - lastline=fline; - lastfile=fcurrent; - if (!is_warning) - errorcount++; - if (errorcount>=3) - error(FATAL_ERROR_OVERWHELMED_BY_BAD); - - return 0; -} - -void errorset(int code,int line) -{ - switch (code) { - case sRESET: - errflag=FALSE; /* start reporting errors */ - break; - case sFORCESET: - errflag=TRUE; /* stop reporting errors */ - break; - case sEXPRMARK: - errstart=fline; /* save start line number */ - break; - case sEXPRRELEASE: - errstart=-1; /* forget start line number */ - sErrLine=-1; - break; - case sSETPOS: - sErrLine=line; - break; - } /* switch */ -} - -/* sc_enablewarning() - * Enables or disables a warning (errors cannot be disabled). - * Initially all warnings are enabled. The compiler does this by setting bits - * for the *disabled* warnings and relying on the array to be zero-initialized. - * - * Parameter enable can be: - * o 0 for disable - * o 1 for enable - * o 2 for toggle - */ -int pc_enablewarning(int number,int enable) -{ - int index; - unsigned char mask; - - if (number<200) - return FALSE; /* errors and fatal errors cannot be disabled */ - number -= 200; - if (number>=NUM_WARNINGS) - return FALSE; - - index=number/8; - mask=(unsigned char)(1 << (number%8)); - switch (enable) { - case 0: - warndisable[index] |= mask; - break; - case 1: - warndisable[index] &= (unsigned char)~mask; - break; - case 2: - warndisable[index] ^= mask; - break; - } /* switch */ - - return TRUE; -} - -#undef SCPACK_TABLE diff --git a/sourcepawn/compiler/sc6.cpp b/sourcepawn/compiler/sc6.cpp deleted file mode 100644 index 5e73e7dd..00000000 --- a/sourcepawn/compiler/sc6.cpp +++ /dev/null @@ -1,969 +0,0 @@ -// vim: set sts=2 ts=8 sw=2 tw=99 et: -/* Pawn compiler - Binary code generation (the "assembler") - * - * Copyright (c) ITB CompuPhase, 1997-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include -#include /* for macro max() */ -#include /* for macro offsetof() */ -#include -#include -#if defined FORTIFY - #include -#endif -#include "lstring.h" -#include "sc.h" -#include "amxdbg.h" -#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ - #include -#endif -#include -#include -#include -#include "smx-builder.h" -#include "memory-buffer.h" - -using namespace sp; -using namespace ke; - -typedef cell (*OPCODE_PROC)(Vector *buffer, char *params, cell opcode); - -typedef struct { - cell opcode; - const char *name; - int segment; /* sIN_CSEG=parse in cseg, sIN_DSEG=parse in dseg */ - OPCODE_PROC func; -} OPCODEC; - -static cell codeindex; /* similar to "code_idx" */ -static cell *LabelTable; /* label table */ -static int writeerror; -static int bytes_in, bytes_out; -static jmp_buf compact_err; - -/* apparently, strtol() does not work correctly on very large (unsigned) - * hexadecimal values */ -static ucell hex2long(const char *s,char **n) -{ - ucell result=0L; - int negate=FALSE; - int digit; - - /* ignore leading whitespace */ - while (*s==' ' || *s=='\t') - s++; - - /* allow a negation sign to create the two's complement of numbers */ - if (*s=='-') { - negate=TRUE; - s++; - } /* if */ - - assert((*s>='0' && *s<='9') || (*s>='a' && *s<='f') || (*s>='a' && *s<='f')); - for ( ;; ) { - if (*s>='0' && *s<='9') - digit=*s-'0'; - else if (*s>='a' && *s<='f') - digit=*s-'a' + 10; - else if (*s>='A' && *s<='F') - digit=*s-'A' + 10; - else - break; /* probably whitespace */ - result=(result<<4) | digit; - s++; - } /* for */ - if (n!=NULL) - *n=(char*)s; - if (negate) - result=(~result)+1; /* take two's complement of the result */ - return (ucell)result; -} - -static ucell getparam(const char *s,char **n) -{ - ucell result=0; - for ( ;; ) { - result+=hex2long(s,(char**)&s); - if (*s!='+') - break; - s++; - } /* for */ - if (n!=NULL) - *n=(char*)s; - return result; -} - -static char *skipwhitespace(char *str) -{ - while (isspace(*str)) - str++; - return str; -} - -static char *stripcomment(char *str) -{ - char *ptr=strchr(str,';'); - if (ptr!=NULL) { - *ptr++='\n'; /* terminate the line, but leave the '\n' */ - *ptr='\0'; - } /* if */ - return str; -} - -static cell noop(Vector *buffer, char *params, cell opcode) -{ - return 0; -} - -static cell set_currentfile(Vector *buffer, char *params, cell opcode) -{ - fcurrent=(short)getparam(params,NULL); - return 0; -} - -static cell parm0(Vector *buffer, char *params, cell opcode) -{ - if (buffer) - buffer->append(opcode); - return opcodes(1); -} - -static cell parm1(Vector *buffer, char *params, cell opcode) -{ - ucell p = getparam(params, nullptr); - if (buffer) { - buffer->append(opcode); - buffer->append(p); - } - return opcodes(1) + opargs(1); -} - -static cell parm2(Vector *buffer, char *params, cell opcode) -{ - ucell p1 = getparam(params, ¶ms); - ucell p2 = getparam(params, nullptr); - if (buffer) { - buffer->append(opcode); - buffer->append(p1); - buffer->append(p2); - } - return opcodes(1) + opargs(2); -} - -static cell parm3(Vector *buffer, char *params, cell opcode) -{ - ucell p1 = getparam(params, ¶ms); - ucell p2 = getparam(params, ¶ms); - ucell p3 = getparam(params, nullptr); - if (buffer) { - buffer->append(opcode); - buffer->append(p1); - buffer->append(p2); - buffer->append(p3); - } - return opcodes(1) + opargs(3); -} - -static cell parm4(Vector *buffer, char *params, cell opcode) -{ - ucell p1 = getparam(params, ¶ms); - ucell p2 = getparam(params, ¶ms); - ucell p3 = getparam(params, ¶ms); - ucell p4 = getparam(params, nullptr); - if (buffer) { - buffer->append(opcode); - buffer->append(p1); - buffer->append(p2); - buffer->append(p3); - buffer->append(p4); - } - return opcodes(1) + opargs(4); -} - -static cell parm5(Vector *buffer, char *params, cell opcode) -{ - ucell p1 = getparam(params, ¶ms); - ucell p2 = getparam(params, ¶ms); - ucell p3 = getparam(params, ¶ms); - ucell p4 = getparam(params, ¶ms); - ucell p5 = getparam(params, nullptr); - if (buffer) { - buffer->append(opcode); - buffer->append(p1); - buffer->append(p2); - buffer->append(p3); - buffer->append(p4); - buffer->append(p5); - } - return opcodes(1) + opargs(5); -} - -static cell do_dump(Vector *buffer, char *params, cell opcode) -{ - int num = 0; - - while (*params != '\0') { - ucell p = getparam(params, ¶ms); - if (buffer) - buffer->append(p); - num++; - while (isspace(*params)) - params++; - } - return num * sizeof(cell); -} - -static cell do_call(Vector *buffer, char *params, cell opcode) -{ - char name[sNAMEMAX+1]; - - int i; - for (i=0; !isspace(*params); i++,params++) { - assert(*params != '\0'); - assert(i < sNAMEMAX); - name[i] = *params; - } - name[i]='\0'; - - cell p; - if (name[0] == 'l' && name[1] == '.') { - // Lookup the label address. - int val = (int)hex2long(name + 2, nullptr); - assert(val >= 0 && val < sc_labnum); - p = LabelTable[val]; - } else { - // Look up the function address; note that the correct file number must - // already have been set (in order for static globals to be found). - symbol *sym = findglb(name, sGLOBAL); - assert(sym->ident == iFUNCTN || sym->ident == iREFFUNC); - assert(sym->vclass == sGLOBAL); - p = sym->addr; - } - - if (buffer) { - buffer->append(opcode); - buffer->append(p); - } - return opcodes(1) + opargs(1); -} - -static cell do_jump(Vector *buffer, char *params, cell opcode) -{ - int i = (int)hex2long(params, nullptr); - assert(i >= 0 && i < sc_labnum); - - if (buffer) { - buffer->append(opcode); - buffer->append(LabelTable[i]); - } - return opcodes(1) + opargs(1); -} - -static cell do_switch(Vector *buffer, char *params, cell opcode) -{ - int i = (int)hex2long(params, nullptr); - assert(i >= 0 && i < sc_labnum); - - if (buffer) { - buffer->append(opcode); - buffer->append(LabelTable[i]); - } - return opcodes(1) + opargs(1); -} - -static cell do_case(Vector *buffer, char *params, cell opcode) -{ - cell v = hex2long(params ,¶ms); - int i = (int)hex2long(params, nullptr); - assert(i >= 0 && i < sc_labnum); - - if (buffer) { - buffer->append(v); - buffer->append(LabelTable[i]); - } - return opcodes(0) + opargs(2); -} - -static OPCODEC opcodelist[] = { - /* node for "invalid instruction" */ - { 0, NULL, 0, noop }, - /* opcodes in sorted order */ - { 78, "add", sIN_CSEG, parm0 }, - { 87, "add.c", sIN_CSEG, parm1 }, - { 14, "addr.alt", sIN_CSEG, parm1 }, - { 13, "addr.pri", sIN_CSEG, parm1 }, - { 30, "align.alt", sIN_CSEG, parm1 }, - { 29, "align.pri", sIN_CSEG, parm1 }, - { 81, "and", sIN_CSEG, parm0 }, - {121, "bounds", sIN_CSEG, parm1 }, - {137, "break", sIN_CSEG, parm0 }, /* version 8 */ - { 49, "call", sIN_CSEG, do_call }, - { 50, "call.pri", sIN_CSEG, parm0 }, - { 0, "case", sIN_CSEG, do_case }, - {130, "casetbl", sIN_CSEG, parm0 }, /* version 1 */ - {118, "cmps", sIN_CSEG, parm1 }, - { 0, "code", sIN_CSEG, set_currentfile }, - {156, "const", sIN_CSEG, parm2 }, /* version 9 */ - { 12, "const.alt", sIN_CSEG, parm1 }, - { 11, "const.pri", sIN_CSEG, parm1 }, - {157, "const.s", sIN_CSEG, parm2 }, /* version 9 */ - { 0, "data", sIN_DSEG, set_currentfile }, - {114, "dec", sIN_CSEG, parm1 }, - {113, "dec.alt", sIN_CSEG, parm0 }, - {116, "dec.i", sIN_CSEG, parm0 }, - {112, "dec.pri", sIN_CSEG, parm0 }, - {115, "dec.s", sIN_CSEG, parm1 }, - { 0, "dump", sIN_DSEG, do_dump }, - { 95, "eq", sIN_CSEG, parm0 }, - {106, "eq.c.alt", sIN_CSEG, parm1 }, - {105, "eq.c.pri", sIN_CSEG, parm1 }, -/*{124, "file", sIN_CSEG, do_file }, */ - {119, "fill", sIN_CSEG, parm1 }, - {162, "genarray", sIN_CSEG, parm1 }, - {163, "genarray.z", sIN_CSEG, parm1 }, - {100, "geq", sIN_CSEG, parm0 }, - { 99, "grtr", sIN_CSEG, parm0 }, - {120, "halt", sIN_CSEG, parm1 }, - { 45, "heap", sIN_CSEG, parm1 }, - { 27, "idxaddr", sIN_CSEG, parm0 }, - { 28, "idxaddr.b", sIN_CSEG, parm1 }, - {109, "inc", sIN_CSEG, parm1 }, - {108, "inc.alt", sIN_CSEG, parm0 }, - {111, "inc.i", sIN_CSEG, parm0 }, - {107, "inc.pri", sIN_CSEG, parm0 }, - {110, "inc.s", sIN_CSEG, parm1 }, - { 86, "invert", sIN_CSEG, parm0 }, - { 55, "jeq", sIN_CSEG, do_jump }, - { 60, "jgeq", sIN_CSEG, do_jump }, - { 59, "jgrtr", sIN_CSEG, do_jump }, - { 58, "jleq", sIN_CSEG, do_jump }, - { 57, "jless", sIN_CSEG, do_jump }, - { 56, "jneq", sIN_CSEG, do_jump }, - { 54, "jnz", sIN_CSEG, do_jump }, - { 52, "jrel", sIN_CSEG, parm1 }, /* always a number */ - { 64, "jsgeq", sIN_CSEG, do_jump }, - { 63, "jsgrtr", sIN_CSEG, do_jump }, - { 62, "jsleq", sIN_CSEG, do_jump }, - { 61, "jsless", sIN_CSEG, do_jump }, - { 51, "jump", sIN_CSEG, do_jump }, - {128, "jump.pri", sIN_CSEG, parm0 }, /* version 1 */ - { 53, "jzer", sIN_CSEG, do_jump }, - { 31, "lctrl", sIN_CSEG, parm1 }, - { 98, "leq", sIN_CSEG, parm0 }, - { 97, "less", sIN_CSEG, parm0 }, - { 25, "lidx", sIN_CSEG, parm0 }, - { 26, "lidx.b", sIN_CSEG, parm1 }, -/*{125, "line", sIN_CSEG, parm2 }, */ - { 2, "load.alt", sIN_CSEG, parm1 }, - {154, "load.both", sIN_CSEG, parm2 }, /* version 9 */ - { 9, "load.i", sIN_CSEG, parm0 }, - { 1, "load.pri", sIN_CSEG, parm1 }, - { 4, "load.s.alt", sIN_CSEG, parm1 }, - {155, "load.s.both",sIN_CSEG, parm2 }, /* version 9 */ - { 3, "load.s.pri", sIN_CSEG, parm1 }, - { 10, "lodb.i", sIN_CSEG, parm1 }, - { 6, "lref.alt", sIN_CSEG, parm1 }, - { 5, "lref.pri", sIN_CSEG, parm1 }, - { 8, "lref.s.alt", sIN_CSEG, parm1 }, - { 7, "lref.s.pri", sIN_CSEG, parm1 }, - { 34, "move.alt", sIN_CSEG, parm0 }, - { 33, "move.pri", sIN_CSEG, parm0 }, - {117, "movs", sIN_CSEG, parm1 }, - { 85, "neg", sIN_CSEG, parm0 }, - { 96, "neq", sIN_CSEG, parm0 }, - {134, "nop", sIN_CSEG, parm0 }, /* version 6 */ - { 84, "not", sIN_CSEG, parm0 }, - { 82, "or", sIN_CSEG, parm0 }, - { 43, "pop.alt", sIN_CSEG, parm0 }, - { 42, "pop.pri", sIN_CSEG, parm0 }, - { 46, "proc", sIN_CSEG, parm0 }, - { 40, "push", sIN_CSEG, parm1 }, - {133, "push.adr", sIN_CSEG, parm1 }, /* version 4 */ - { 37, "push.alt", sIN_CSEG, parm0 }, - { 39, "push.c", sIN_CSEG, parm1 }, - { 36, "push.pri", sIN_CSEG, parm0 }, - { 38, "push.r", sIN_CSEG, parm1 }, /* obsolete (never generated) */ - { 41, "push.s", sIN_CSEG, parm1 }, - {139, "push2", sIN_CSEG, parm2 }, /* version 9 */ - {141, "push2.adr", sIN_CSEG, parm2 }, /* version 9 */ - {138, "push2.c", sIN_CSEG, parm2 }, /* version 9 */ - {140, "push2.s", sIN_CSEG, parm2 }, /* version 9 */ - {143, "push3", sIN_CSEG, parm3 }, /* version 9 */ - {145, "push3.adr", sIN_CSEG, parm3 }, /* version 9 */ - {142, "push3.c", sIN_CSEG, parm3 }, /* version 9 */ - {144, "push3.s", sIN_CSEG, parm3 }, /* version 9 */ - {147, "push4", sIN_CSEG, parm4 }, /* version 9 */ - {149, "push4.adr", sIN_CSEG, parm4 }, /* version 9 */ - {146, "push4.c", sIN_CSEG, parm4 }, /* version 9 */ - {148, "push4.s", sIN_CSEG, parm4 }, /* version 9 */ - {151, "push5", sIN_CSEG, parm5 }, /* version 9 */ - {153, "push5.adr", sIN_CSEG, parm5 }, /* version 9 */ - {150, "push5.c", sIN_CSEG, parm5 }, /* version 9 */ - {152, "push5.s", sIN_CSEG, parm5 }, /* version 9 */ - { 47, "ret", sIN_CSEG, parm0 }, - { 48, "retn", sIN_CSEG, parm0 }, - { 32, "sctrl", sIN_CSEG, parm1 }, - { 73, "sdiv", sIN_CSEG, parm0 }, - { 74, "sdiv.alt", sIN_CSEG, parm0 }, - {104, "sgeq", sIN_CSEG, parm0 }, - {103, "sgrtr", sIN_CSEG, parm0 }, - { 65, "shl", sIN_CSEG, parm0 }, - { 69, "shl.c.alt", sIN_CSEG, parm1 }, - { 68, "shl.c.pri", sIN_CSEG, parm1 }, - { 66, "shr", sIN_CSEG, parm0 }, - { 71, "shr.c.alt", sIN_CSEG, parm1 }, - { 70, "shr.c.pri", sIN_CSEG, parm1 }, - { 94, "sign.alt", sIN_CSEG, parm0 }, - { 93, "sign.pri", sIN_CSEG, parm0 }, - {102, "sleq", sIN_CSEG, parm0 }, - {101, "sless", sIN_CSEG, parm0 }, - { 72, "smul", sIN_CSEG, parm0 }, - { 88, "smul.c", sIN_CSEG, parm1 }, -/*{127, "srange", sIN_CSEG, parm2 }, -- version 1 */ - { 20, "sref.alt", sIN_CSEG, parm1 }, - { 19, "sref.pri", sIN_CSEG, parm1 }, - { 22, "sref.s.alt", sIN_CSEG, parm1 }, - { 21, "sref.s.pri", sIN_CSEG, parm1 }, - { 67, "sshr", sIN_CSEG, parm0 }, - { 44, "stack", sIN_CSEG, parm1 }, - {165, "stackadjust",sIN_CSEG, parm1 }, - { 0, "stksize", 0, noop }, - { 16, "stor.alt", sIN_CSEG, parm1 }, - { 23, "stor.i", sIN_CSEG, parm0 }, - { 15, "stor.pri", sIN_CSEG, parm1 }, - { 18, "stor.s.alt", sIN_CSEG, parm1 }, - { 17, "stor.s.pri", sIN_CSEG, parm1 }, - {164, "stradjust.pri", sIN_CSEG, parm0 }, - { 24, "strb.i", sIN_CSEG, parm1 }, - { 79, "sub", sIN_CSEG, parm0 }, - { 80, "sub.alt", sIN_CSEG, parm0 }, - {132, "swap.alt", sIN_CSEG, parm0 }, /* version 4 */ - {131, "swap.pri", sIN_CSEG, parm0 }, /* version 4 */ - {129, "switch", sIN_CSEG, do_switch }, /* version 1 */ -/*{126, "symbol", sIN_CSEG, do_symbol }, */ -/*{136, "symtag", sIN_CSEG, parm1 }, -- version 7 */ - {123, "sysreq.c", sIN_CSEG, parm1 }, - {135, "sysreq.n", sIN_CSEG, parm2 }, /* version 9 (replaces SYSREQ.d from earlier version) */ - {122, "sysreq.pri", sIN_CSEG, parm0 }, - {161, "tracker.pop.setheap", sIN_CSEG, parm0 }, - {160, "tracker.push.c", sIN_CSEG, parm1 }, - { 76, "udiv", sIN_CSEG, parm0 }, - { 77, "udiv.alt", sIN_CSEG, parm0 }, - { 75, "umul", sIN_CSEG, parm0 }, - { 35, "xchg", sIN_CSEG, parm0 }, - { 83, "xor", sIN_CSEG, parm0 }, - { 91, "zero", sIN_CSEG, parm1 }, - { 90, "zero.alt", sIN_CSEG, parm0 }, - { 89, "zero.pri", sIN_CSEG, parm0 }, - { 92, "zero.s", sIN_CSEG, parm1 }, -}; - -#define MAX_INSTR_LEN 30 -static int findopcode(char *instr,int maxlen) -{ - int low,high,mid,cmp; - char str[MAX_INSTR_LEN]; - - if (maxlen>=MAX_INSTR_LEN) - return 0; - strlcpy(str,instr,maxlen+1); - /* look up the instruction with a binary search - * the assembler is case insensitive to instructions (but case sensitive - * to symbols) - */ - low=1; /* entry 0 is reserved (for "not found") */ - high=(sizeof opcodelist / sizeof opcodelist[0])-1; - while (low0) - low=mid+1; - else - high=mid; - } /* while */ - - assert(low==high); - if (stricmp(str,opcodelist[low].name)==0) - return low; /* found */ - return 0; /* not found, return special index */ -} - -// This pass is necessary because the code addresses of labels is only known -// after the peephole optimization flag. Labels can occur inside expressions -// (e.g. the conditional operator), which are optimized. -static void relocate_labels(void *fin) -{ - if (sc_labnum <= 0) - return; - - assert(!LabelTable); - LabelTable = (cell *)calloc(sc_labnum, sizeof(cell)); - - char line[256]; - cell codeindex = 0; - - pc_resetasm(fin); - while (pc_readasm(fin, line, sizeof(line))) { - stripcomment(line); - - char *instr = skipwhitespace(line); - if (*instr == '\0') // Ignore empty lines. - continue; - - if (tolower(*instr) == 'l' && *(instr + 1) == '.') { - int lindex = (int)hex2long(instr + 2, nullptr); - assert(lindex >= 0 && lindex < sc_labnum); - LabelTable[lindex] = codeindex; - } else { - // Get to the end of the instruction (make use of the '\n' that fgets() - // added at the end of the line; this way we *always* drop on a whitespace - // character. - char *params; - for (params = instr; *params != '\0' && !isspace(*params); params++) { - // Nothing. - } - assert(params > instr); - - int op_index = findopcode(instr, (int)(params - instr)); - OPCODEC &op = opcodelist[op_index]; - if (!op.name) { - *params = '\0'; - error(104, instr); - } - - if (op.segment == sIN_CSEG) - codeindex += op.func(nullptr, skipwhitespace(params), op.opcode); - } - } -} - -// Generate code or data into a buffer. -static void generate_segment(Vector *buffer, void *fin, int pass) -{ - pc_resetasm(fin); - - char line[255]; - while (pc_readasm(fin, line, sizeof(line))) { - stripcomment(line); - char *instr = skipwhitespace(line); - - // Ignore empty lines and labels. - if (*instr=='\0' || (tolower(*instr) == 'l' && *(instr + 1)=='.')) - continue; - - // Get to the end of the instruction (make use of the '\n' that fgets() - // added at the end of the line; this way we will *always* drop on a - // whitespace character) */ - char *params; - for (params=instr; *params != '\0' && !isspace(*params); params++) { - // Do nothing. - } - assert(params > instr); - - int op_index = findopcode(instr, (int)(params-instr)); - OPCODEC &op = opcodelist[op_index]; - assert(op.name != nullptr); - - if (op.segment != pass) - continue; - - op.func(buffer, skipwhitespace(params), op.opcode); - } -} - -#if !defined NDEBUG -// The opcode list should be sorted by name. -class VerifyOpcodeSorting -{ - public: - VerifyOpcodeSorting() { - assert(opcodelist[1].name!=NULL); - for (int i = 2; i<(sizeof opcodelist / sizeof opcodelist[0]); i++) { - assert(opcodelist[i].name!=NULL); - assert(stricmp(opcodelist[i].name,opcodelist[i-1].name)>0); - } /* for */ - } -} sVerifyOpcodeSorting; -#endif - -static int sort_by_addr(const void *a1, const void *a2) -{ - symbol *s1 = *(symbol **)a1; - symbol *s2 = *(symbol **)a2; - return s1->addr - s2->addr; -} - -// Helper for parsing a debug string. Debug strings look like this: -// L:40 10 -class DebugString -{ - public: - DebugString() : kind_('\0'), str_(nullptr) - { } - DebugString(char *str) - : kind_(str[0]), - str_(str) - { - assert(str_[1] == ':'); - str_ += 2; - } - char kind() const { - return kind_; - } - ucell parse() { - return hex2long(str_, &str_); - } - char *skipspaces() { - str_ = ::skipwhitespace(str_); - return str_; - } - void expect(char c) { - assert(*str_ == c); - str_++; - } - char *skipto(char c) { - str_ = strchr(str_, c); - return str_; - } - char getc() { - return *str_++; - } - - private: - char kind_; - char *str_; -}; - -typedef SmxBlobSection SmxDebugInfoSection; -typedef SmxListSection SmxDebugLineSection; -typedef SmxListSection SmxDebugFileSection; -typedef SmxListSection SmxTagSection; -typedef SmxBlobSection SmxDebugSymbolsSection; -typedef SmxBlobSection SmxDebugNativesSection; -typedef Vector SymbolList; - -static void append_debug_tables(SmxBuilder *builder, StringPool &pool, Ref names, SymbolList &nativeList) -{ - // We use a separate name table for historical reasons that are no longer - // necessary. In the future we should just alias this to ".names". - Ref dbgnames = new SmxNameTable(".dbg.strings"); - Ref info = new SmxDebugInfoSection(".dbg.info"); - Ref lines = new SmxDebugLineSection(".dbg.lines"); - Ref files = new SmxDebugFileSection(".dbg.files"); - Ref symbols = new SmxDebugSymbolsSection(".dbg.symbols"); - Ref natives = new SmxDebugNativesSection(".dbg.natives"); - Ref tags = new SmxTagSection(".tags"); - - stringlist *dbgstrs = get_dbgstrings(); - - // State for tracking which file we're on. We replicate the original AMXDBG - // behavior here which excludes duplicate addresses. - ucell prev_file_addr = 0; - const char *prev_file_name = nullptr; - - // Add debug data. - for (stringlist *iter = dbgstrs; iter; iter = iter->next) { - if (iter->line[0] == '\0') - continue; - - DebugString str(iter->line); - switch (str.kind()) { - case 'F': - { - ucell codeidx = str.parse(); - if (codeidx != prev_file_addr) { - if (prev_file_name) { - sp_fdbg_file_t &entry = files->add(); - entry.addr = prev_file_addr; - entry.name = dbgnames->add(pool, prev_file_name); - } - prev_file_addr = codeidx; - } - prev_file_name = str.skipspaces(); - break; - } - - case 'L': - { - sp_fdbg_line_t &entry = lines->add(); - entry.addr = str.parse(); - entry.line = str.parse(); - break; - } - - case 'S': - { - sp_fdbg_symbol_t sym; - sp_fdbg_arraydim_t dims[sDIMEN_MAX]; - - sym.addr = str.parse(); - sym.tagid = str.parse(); - - str.skipspaces(); - str.expect(':'); - char *name = str.skipspaces(); - char *nameend = str.skipto(' '); - Atom *atom = pool.add(name, nameend - name); - - sym.codestart = str.parse(); - sym.codeend = str.parse(); - sym.ident = (char)str.parse(); - sym.vclass = (char)str.parse(); - sym.dimcount = 0; - sym.name = dbgnames->add(atom); - - info->header().num_syms++; - - str.skipspaces(); - if (str.getc() == '[') { - info->header().num_arrays++; - for (char *ptr = str.skipspaces(); *ptr != ']'; ptr = str.skipspaces()) { - dims[sym.dimcount].tagid = str.parse(); - str.skipspaces(); - str.expect(':'); - dims[sym.dimcount].size = str.parse(); - sym.dimcount++; - } - } - - symbols->add(&sym, sizeof(sym)); - symbols->add(dims, sizeof(dims[0]) * sym.dimcount); - break; - } - } - } - - // Add the last file. - if (prev_file_name) { - sp_fdbg_file_t &entry = files->add(); - entry.addr = prev_file_addr; - entry.name = dbgnames->add(pool, prev_file_name); - } - - // Build the tags table. - for (constvalue *constptr = tagname_tab.next; constptr; constptr = constptr->next) { - assert(strlen(constptr->name)>0); - - sp_file_tag_t &tag = tags->add(); - tag.tag_id = constptr->value; - tag.name = names->add(pool, constptr->name); - } - - // Finish up debug header statistics. - info->header().num_files = files->count(); - info->header().num_lines = lines->count(); - - // Write natives. - sp_fdbg_ntvtab_t natives_header; - natives_header.num_entries = nativeList.length(); - natives->add(&natives_header, sizeof(natives_header)); - - for (size_t i = 0; i < nativeList.length(); i++) { - symbol *sym = nativeList[i]; - - sp_fdbg_native_t info; - info.index = i; - info.name = dbgnames->add(pool, sym->name); - info.tagid = sym->tag; - info.nargs = 0; - for (arginfo *arg = sym->dim.arglist; arg->ident; arg++) - info.nargs++; - natives->add(&info, sizeof(info)); - - for (arginfo *arg = sym->dim.arglist; arg->ident; arg++) { - sp_fdbg_ntvarg_t argout; - argout.ident = arg->ident; - argout.tagid = arg->tags[0]; - argout.dimcount = arg->numdim; - argout.name = dbgnames->add(pool, arg->name); - natives->add(&argout, sizeof(argout)); - - for (int j = 0; j < argout.dimcount; j++) { - sp_fdbg_arraydim_t dim; - dim.tagid = arg->idxtag[j]; - dim.size = arg->dim[j]; - natives->add(&dim, sizeof(dim)); - } - } - } - - // Add these in the same order SourceMod 1.6 added them. - builder->add(files); - builder->add(symbols); - builder->add(lines); - builder->add(natives); - builder->add(dbgnames); - builder->add(info); - builder->add(tags); -} - -typedef SmxListSection SmxNativeSection; -typedef SmxListSection SmxPublicSection; -typedef SmxListSection SmxPubvarSection; -typedef SmxBlobSection SmxDataSection; -typedef SmxBlobSection SmxCodeSection; - -static void assemble_to_buffer(MemoryBuffer *buffer, void *fin) -{ - StringPool pool; - SmxBuilder builder; - Ref natives = new SmxNativeSection(".natives"); - Ref publics = new SmxPublicSection(".publics"); - Ref pubvars = new SmxPubvarSection(".pubvars"); - Ref data = new SmxDataSection(".data"); - Ref code = new SmxCodeSection(".code"); - Ref names = new SmxNameTable(".names"); - - Vector nativeList; - - // Build the easy symbol tables. - for (symbol *sym=glbtab.next; sym; sym=sym->next) { - if (sym->ident==iFUNCTN) { - if ((sym->usage & uNATIVE)!=0 && (sym->usage & uREAD)!=0 && sym->addr >= 0) { - // Natives require special handling, so we save them for later. - nativeList.append(sym); - } else if ((sym->usage & uPUBLIC)!=0 && (sym->usage & uDEFINE)!=0) { - sp_file_publics_t &pubfunc = publics->add(); - pubfunc.address = sym->addr; - pubfunc.name = names->add(pool, sym->name); - } - } else if (sym->ident==iVARIABLE || sym->ident == iARRAY || sym->ident == iREFARRAY) { - if ((sym->usage & uPUBLIC)!=0 && (sym->usage & (uREAD | uWRITTEN))!=0) { - sp_file_pubvars_t &pubvar = pubvars->add(); - pubvar.address = sym->addr; - pubvar.name = names->add(pool, sym->name); - } - } - } - - // Shuffle natives to be in address order. - qsort(nativeList.buffer(), nativeList.length(), sizeof(symbol *), sort_by_addr); - for (size_t i = 0; i < nativeList.length(); i++) { - symbol *sym = nativeList[i]; - assert(size_t(sym->addr) == i); - - sp_file_natives_t &entry = natives->add(); - - char testalias[sNAMEMAX + 1]; - if (lookup_alias(testalias, sym->name)) - entry.name = names->add(pool, "@"); - else - entry.name = names->add(pool, sym->name); - } - - // Relocate all labels in the assembly buffer. - relocate_labels(fin); - - // Generate buffers. - Vector code_buffer, data_buffer; - generate_segment(&code_buffer, fin, sIN_CSEG); - generate_segment(&data_buffer, fin, sIN_DSEG); - - // Set up the code section. - code->header().codesize = code_buffer.length() * sizeof(cell); - code->header().cellsize = sizeof(cell); - code->header().codeversion = SmxConsts::CODE_VERSION_JIT_1_1; - code->header().flags = CODEFLAG_DEBUG; - code->header().main = 0; - code->header().code = sizeof(sp_file_code_t); - code->setBlob((uint8_t *)code_buffer.buffer(), code_buffer.length() * sizeof(cell)); - - // Set up the data section. Note pre-SourceMod 1.7, the |memsize| was - // computed as AMX::stp, which included the entire memory size needed to - // store the file. Here (in 1.7+), we allocate what is actually needed - // by the plugin. - data->header().datasize = data_buffer.length() * sizeof(cell); - data->header().memsize = - data->header().datasize + - glb_declared * sizeof(cell) + - pc_stksize * sizeof(cell); - data->header().data = sizeof(sp_file_data_t); - data->setBlob((uint8_t *)data_buffer.buffer(), data_buffer.length() * sizeof(cell)); - - free(LabelTable); - LabelTable = nullptr; - - // Add tables in the same order SourceMod 1.6 added them. - builder.add(code); - builder.add(data); - builder.add(publics); - builder.add(pubvars); - builder.add(natives); - builder.add(names); - append_debug_tables(&builder, pool, names, nativeList); - - builder.write(buffer); -} - -static void splat_to_binary(const char *binfname, void *bytes, size_t size) -{ - // Note: error 161 will setjmp(), which skips destructors :( - FILE *fp = fopen(binfname, "wb"); - if (!fp) { - error(FATAL_ERROR_WRITE, binfname); - return; - } - if (fwrite(bytes, 1, size, fp) != size) { - fclose(fp); - error(FATAL_ERROR_WRITE, binfname); - return; - } - fclose(fp); -} - -void assemble(const char *binfname, void *fin) -{ - MemoryBuffer buffer; - assemble_to_buffer(&buffer, fin); - - // Buffer compression logic. - sp_file_hdr_t *header = (sp_file_hdr_t *)buffer.bytes(); - size_t region_size = header->imagesize - header->dataoffs; - size_t zbuf_max = compressBound(region_size); - Bytef *zbuf = (Bytef *)malloc(zbuf_max); - - uLong new_disksize = zbuf_max; - int err = compress2( - zbuf, - &new_disksize, - (Bytef *)(buffer.bytes() + header->dataoffs), - region_size, - Z_BEST_COMPRESSION - ); - if (err != Z_OK) { - free(zbuf); - pc_printf("Unable to compress, error %d\n", err); - pc_printf("Falling back to no compression.\n"); - splat_to_binary(binfname, buffer.bytes(), buffer.size()); - return; - } - - header->disksize = new_disksize + header->dataoffs; - header->compression = SmxConsts::FILE_COMPRESSION_GZ; - - buffer.rewind(header->dataoffs); - buffer.write(zbuf, new_disksize); - free(zbuf); - - splat_to_binary(binfname, buffer.bytes(), buffer.size()); -} diff --git a/sourcepawn/compiler/sc7-in.scp b/sourcepawn/compiler/sc7-in.scp deleted file mode 100644 index ddbfb9b8..00000000 --- a/sourcepawn/compiler/sc7-in.scp +++ /dev/null @@ -1,2027 +0,0 @@ -/* Pawn compiler - Peephole optimizer "sequences" strings (plain - * and compressed formats) - * - * Copyright (c) ITB CompuPhase, 2000-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ - -int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]); - -#define SCPACK_TERMINATOR , /* end each section with a comma */ - -#define SCPACK_TABLE sequences_table -/*-*SCPACK start of pair table, do not change or remove this line */ -unsigned char sequences_table[][2] = { - {49,33}, {37,128}, {32,129}, {32,37}, {114,105}, {112,132}, {46,133}, {97,100}, {46,97}, {136,108}, {137,116}, {115,104}, {111,135}, {117,139}, {112,141}, {108,140}, - {131,50}, {144,33}, {46,115}, {138,33}, {59,36}, {134,130}, {143,146}, {115,116}, {134,145}, {110,151}, {111,153}, {99,154}, {112,147}, {135,100}, {134,33}, {114,33}, - {111,156}, {112,160}, {46,99}, {138,130}, {142,158}, {131,51}, {150,152}, {112,33}, {120,167}, {101,168}, {148,169}, {97,159}, {112,171}, {148,172}, {165,33}, {173,142}, - {122,101}, {176,114}, {101,113}, {110,100}, {149,164}, {157,114}, {33,161}, {131,49}, {103,33}, {157,33}, {104,184}, {99,186}, {120,187}, {98,111}, {118,101}, {111,190}, - {109,191}, {130,170}, {131,52}, {106,177}, {138,145}, {180,166}, {192,147}, {108,162}, {163,166}, {143,149}, {115,174}, {117,179}, {139,199}, {203,202}, {189,205}, {105,100}, - {115,103}, {115,108}, {207,120}, {195,130}, {46,135}, {178,33}, {212,114}, {204,134}, {155,149}, {142,162}, {183,145}, {150,149}, {143,152}, {194,33}, {130,175}, {97,179}, - {177,111}, {182,185}, {143,46}, {183,144}, {155,152}, {145,175}, {114,101}, {230,102}, {108,231}, {101,115}, {233,115}, {114,116}, {142,147}, {105,33}, {155,163}, {178,130}, - {215,32}, {240,50}, {143,196}, {155,197}, {181,197}, {181,200}, {108,210}, {46,98}, {241,225}, {208,235}, {209,234}, {224,158}, {143,163}, {150,163}, {155,200} -}; -/*-*SCPACK end of pair table, do not change or remove this line */ - -#define seqsize(o,p) (opcodes(o)+opargs(p)) -typedef struct { - const char *find; - const char *replace; - int savesize; /* number of bytes saved (in bytecode) */ -} SETUP_SEQUENCE; -typedef struct { - char *find; - char *replace; - int savesize; /* number of bytes saved (in bytecode) */ -} SEQUENCE; -static SETUP_SEQUENCE sequences_cmp[] = { - /* A very common sequence in four varieties - * load.s.pri n1 load.s.pri n2 - * push.pri load.s.alt n1 - * load.s.pri n2 - - * pop.alt - - * -------------------------------------- - * load.pri n1 load.s.pri n2 - * push.pri load.alt n1 - * load.s.pri n2 - - * pop.alt - - * -------------------------------------- - * load.s.pri n1 load.pri n2 - * push.pri load.s.alt n1 - * load.pri n2 - - * pop.alt - - * -------------------------------------- - * load.pri n1 load.pri n2 - * push.pri load.alt n1 - * load.pri n2 - - * pop.alt - - */ - { - #ifdef SCPACK - "load.s.pri %1!push.pri!load.s.pri %2!pop.alt!", - "load.s.pri %2!load.s.alt %1!", - #else - "\226\305\241", - "\246\375", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.pri %1!push.pri!load.s.pri %2!pop.alt!", - "load.s.pri %2!load.alt %1!", - #else - "\217\305\241", - "\246\374", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.s.pri %1!push.pri!load.pri %2!pop.alt!", - "load.pri %2!load.s.alt %1!", - #else - "\226\264\334\241", - "\334\375", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.pri %1!push.pri!load.pri %2!pop.alt!", - "load.pri %2!load.alt %1!", - #else - "\217\264\334\241", - "\334\374", - #endif - seqsize(4,2) - seqsize(2,2) - }, - /* (#1#) The above also occurs with "addr.pri" (array - * indexing) as the first line; so that adds 2 cases. - */ - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.s.pri %2!pop.alt!", - "addr.alt %1!load.s.pri %2!", - #else - "\364\241", - "\365", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.pri %2!pop.alt!", - "addr.alt %1!load.pri %2!", - #else - "\265\264\334\241", - "\265\243\334", - #endif - seqsize(4,2) - seqsize(2,2) - }, - /* And the same sequence with const.pri as either the first - * or the second load instruction: four more cases. - */ - { - #ifdef SCPACK - "const.pri %1!push.pri!load.s.pri %2!pop.alt!", - "load.s.pri %2!const.alt %1!", - #else - "\363\241", - "\246\356", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!load.pri %2!pop.alt!", - "load.pri %2!const.alt %1!", - #else - "\233\264\334\241", - "\334\356", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.s.pri %1!push.pri!const.pri %2!pop.alt!", - "const.pri %2!load.s.alt %1!", - #else - "\226\264\344\241", - "\344\375", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.pri %1!push.pri!const.pri %2!pop.alt!", - "const.pri %2!load.alt %1!", - #else - "\217\264\344\241", - "\344\374", - #endif - seqsize(4,2) - seqsize(2,2) - }, - /* The same as above, but now with "addr.pri" (array - * indexing) on the first line and const.pri on - * the second. - */ - { - #ifdef SCPACK - "addr.pri %1!push.pri!const.pri %2!pop.alt!", - "addr.alt %1!const.pri %2!", - #else - "\265\264\344\241", - "\265\243\344", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "addr.pri %1!push.pri!zero.pri!pop.alt!", - "addr.alt %1!zero.pri!", - #else - "\265\264\373\241", - "\265\243\373", - #endif - seqsize(4,1) - seqsize(2,1) - }, - /* ??? add references */ - /* Chained relational operators can contain sequences like: - * move.pri load.s.pri n1 - * push.pri - - * load.s.pri n1 - - * pop.alt - - * The above also accurs for "load.pri" and for "const.pri", - * so add another two cases. - */ - { - #ifdef SCPACK - "move.pri!push.pri!load.s.pri %1!pop.alt!", - "load.s.pri %1!", - #else - "\300\236\244\333\241", - "\333", - #endif - seqsize(4,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "move.pri!push.pri!load.pri %1!pop.alt!", - "load.pri %1!", - #else - "\300\236\244\311\241", - "\311", - #endif - seqsize(4,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "move.pri!push.pri!const.pri %1!pop.alt!", - "const.pri %1!", - #else - "\300\236\244\330\241", - "\330", - #endif - seqsize(4,1) - seqsize(1,1) - }, - /* More optimizations for chained relational operators; the - * continuation sequences can be simplified if they turn out - * to be termination sequences: - * xchg sless also for sless, sgeq and sleq - * sgrtr pop.alt - * swap.alt and - * and ;$exp - * pop.alt - - * ;$exp - - * -------------------------------------- - * xchg sless also for sless, sgeq and sleq - * sgrtr pop.alt - * swap.alt and - * and jzer n1 - * pop.alt - - * jzer n1 - - * -------------------------------------- - * xchg jsgeq n1 also for sless, sgeq and sleq - * sgrtr ;$exp (occurs for non-chained comparisons) - * jzer n1 - - * ;$exp - - * -------------------------------------- - * xchg sless also for sless, sgeq and sleq - * sgrtr ;$exp (occurs for non-chained comparisons) - * ;$exp - - */ - { - #ifdef SCPACK - "xchg!sgrtr!swap.alt!and!pop.alt!;$exp!", - "sless!pop.alt!and!;$exp!", - #else - "\274\371\237swa\234\337\266\252", - "\372\266\337!\252", - #endif - seqsize(5,0) - seqsize(3,0) - }, - { - #ifdef SCPACK - "xchg!sless!swap.alt!and!pop.alt!;$exp!", - "sgrtr!pop.alt!and!;$exp!", - #else - "\274\372!swa\234\337\266\252", - "\371\237\241\337!\252", - #endif - seqsize(5,0) - seqsize(3,0) - }, - { - #ifdef SCPACK - "xchg!sgeq!swap.alt!and!pop.alt!;$exp!", - "sleq!pop.alt!and!;$exp!", - #else - "\274\320\325swa\234\337\266\252", - "\321\262\266\337!\252", - #endif - seqsize(5,0) - seqsize(3,0) - }, - { - #ifdef SCPACK - "xchg!sleq!swap.alt!and!pop.alt!;$exp!", - "sgeq!pop.alt!and!;$exp!", - #else - "\274\321\325swa\234\337\266\252", - "\320\262\266\337!\252", - #endif - seqsize(5,0) - seqsize(3,0) - }, - { - #ifdef SCPACK - "xchg!sgrtr!swap.alt!and!pop.alt!jzer %1!", - "sless!pop.alt!and!jzer %1!", - #else - "\274\371\237swa\234\337\266\323", - "\372\266\337!\323", - #endif - seqsize(5,0) - seqsize(3,0) - }, - { - #ifdef SCPACK - "xchg!sless!swap.alt!and!pop.alt!jzer %1!", - "sgrtr!pop.alt!and!jzer %1!", - #else - "\274\372!swa\234\337\266\323", - "\371\237\241\337!\323", - #endif - seqsize(5,0) - seqsize(3,0) - }, - { - #ifdef SCPACK - "xchg!sgeq!swap.alt!and!pop.alt!jzer %1!", - "sleq!pop.alt!and!jzer %1!", - #else - "\274\320\325swa\234\337\266\323", - "\321\262\266\337!\323", - #endif - seqsize(5,0) - seqsize(3,0) - }, - { - #ifdef SCPACK - "xchg!sleq!swap.alt!and!pop.alt!jzer %1!", - "sgeq!pop.alt!and!jzer %1!", - #else - "\274\321\325swa\234\337\266\323", - "\320\262\266\337!\323", - #endif - seqsize(5,0) - seqsize(3,0) - }, - { - #ifdef SCPACK - "xchg!sgrtr!jzer %1!;$exp!", - "jsgeq %1!;$exp!", - #else - "\274\371\237\303\301", - "j\320\262\301", - #endif - seqsize(3,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "xchg!sless!jzer %1!;$exp!", - "jsleq %1!;$exp!", - #else - "\274\372!\303\301", - "j\321\262\301", - #endif - seqsize(3,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "xchg!sgeq!jzer %1!;$exp!", - "jsgrtr %1!;$exp!", - #else - "\274\320\325\303\301", - "j\371r\301", - #endif - seqsize(3,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "xchg!sleq!jzer %1!;$exp!", - "jsless %1!;$exp!", - #else - "\274\321\325\303\301", - "j\372\301", - #endif - seqsize(3,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "xchg!sgrtr!;$exp!", - "sless!;$exp!", - #else - "\274\371\237\252", - "\372!\252", - #endif - seqsize(2,0) - seqsize(1,0) - }, - { - #ifdef SCPACK - "xchg!sless!;$exp!", - "sgrtr!;$exp!", - #else - "\274\372!\252", - "\371\237\252", - #endif - seqsize(2,0) - seqsize(1,0) - }, - { - #ifdef SCPACK - "xchg!sgeq!;$exp!", - "sleq!;$exp!", - #else - "\274\320\325\252", - "\321\325\252", - #endif - seqsize(2,0) - seqsize(1,0) - }, - { - #ifdef SCPACK - "xchg!sleq!;$exp!", - "sgeq!;$exp!", - #else - "\274\321\325\252", - "\320\325\252", - #endif - seqsize(2,0) - seqsize(1,0) - }, - /* The entry to chained operators is also opt to optimization - * load.s.pri n1 load.s.pri n2 - * load.s.alt n2 load.s.alt n1 - * xchg - - * -------------------------------------- - * load.s.pri n1 load.pri n2 - * load.alt n2 load.s.alt n1 - * xchg - - * -------------------------------------- - * load.s.pri n1 const.pri n2 - * const.alt n2 load.s.alt n1 - * xchg - - * -------------------------------------- - * and all permutations... - */ - { - #ifdef SCPACK - "load.s.pri %1!load.s.alt %2!xchg!", - "load.s.pri %2!load.s.alt %1!", - #else - "\333\226\304\274", - "\246\375", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.s.pri %1!load.alt %2!xchg!", - "load.pri %2!load.s.alt %1!", - #else - "\333\362\274", - "\334\375", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.s.pri %1!const.alt %2!xchg!", - "const.pri %2!load.s.alt %1!", - #else - "\333\233\304\274", - "\344\375", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.pri %1!load.s.alt %2!xchg!", - "load.s.pri %2!load.alt %1!", - #else - "\311\226\304\274", - "\246\374", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.pri %1!load.alt %2!xchg!", - "load.pri %2!load.alt %1!", - #else - "\311\362\274", - "\334\374", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.pri %1!const.alt %2!xchg!", - "const.pri %2!load.alt %1!", - #else - "\311\233\304\274", - "\344\374", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "const.pri %1!load.s.alt %2!xchg!", - "load.s.pri %2!const.alt %1!", - #else - "\330\226\304\274", - "\246\356", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "const.pri %1!load.alt %2!xchg!", - "load.pri %2!const.alt %1!", - #else - "\330\362\274", - "\334\356", - #endif - seqsize(3,2) - seqsize(2,2) - }, - /* some sequences where PRI is moved to ALT can be optimized - * further when considering what follows - * move.alt const.alt n1 - * const.pri %1 - - * xchg - - * (also for load.s.pri and load.pri) - * -------------------------------------- - * lref.pri %1 lref.alt %1 - * move.alt [load.pri %2] - * [load.pri %2] - - * (where [load.pri %2] may also be another operatrion loading PRI) - */ - { - #ifdef SCPACK - "move.alt!const.pri %1!xchg!", - "const.alt %1!", - #else - "\306\330\274", - "\356", - #endif - seqsize(3,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "move.alt!load.pri %1!xchg!", - "load.alt %1!", - #else - "\306\311\274", - "\374", - #endif - seqsize(3,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "move.alt!load.s.pri %1!xchg!", - "load.s.alt %1!", - #else - "\306\333\274", - "\375", - #endif - seqsize(3,1) - seqsize(1,1) - }, - /* ----- */ - { - #ifdef SCPACK - "lref.pri %1!move.alt!load.pri %2!", - "lref.alt %1!load.pri %2!", - #else - "\350\225\306\334", - "\350\243\334", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "lref.pri %1!move.alt!load.s.pri %2!", - "lref.alt %1!load.s.pri %2!", - #else - "\350\225\306\246", - "\350\310", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "lref.pri %1!move.alt!const.pri %2!", - "lref.alt %1!const.pri %2!", - #else - "\350\225\306\344", - "\350\243\344", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "lref.s.pri %1!move.alt!load.pri %2!", - "lref.s.alt %1!load.pri %2!", - #else - "\350\222\225\306\334", - "\350\222\243\334", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "lref.s.pri %1!move.alt!load.s.pri %2!", - "lref.s.alt %1!load.s.pri %2!", - #else - "\350\222\225\306\246", - "\350\222\310", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "lref.s.pri %1!move.alt!const.pri %2!", - "lref.s.alt %1!const.pri %2!", - #else - "\350\222\225\306\344", - "\350\222\243\344", - #endif - seqsize(3,2) - seqsize(2,2) - }, - /* Array indexing can merit from special instructions. - * Simple indexed array lookup can be optimized quite - * a bit. - * addr.pri n1 addr.alt n1 - * push.pri load.s.pri n2 - * load.s.pri n2 bounds n3 - * bounds n3 lidx.b n4 - * shl.c.pri n4 - - * pop.alt - - * add - - * load.i - - * - * And to prepare for storing a value in an array - * addr.pri n1 addr.alt n1 - * push.pri load.s.pri n2 - * load.s.pri n2 bounds n3 - * bounds n3 idxaddr.b n4 - * shl.c.pri n4 - - * pop.alt - - * add - - * - * Notes (additional cases): - * 1. instruction addr.pri can also be const.pri (for - * global arrays) - * 2. the bounds instruction can be absent - * 3. when "n4" (the shift value) is the 2 (with 32-bit cells), use the - * even more optimal instructions LIDX and IDDXADDR - * - * If the array index is more complex, one can only optimize - * the last four instructions: - * shl.c.pri n1 pop.alt - * pop.alt lidx.b n1 - * add - - * loadi - - * -------------------------------------- - * shl.c.pri n1 pop.alt - * pop.alt idxaddr.b n1 - * add - - */ -#if !defined BIT16 - /* loading from array, "cell" shifted */ - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!load.i!", - "addr.alt %1!load.s.pri %2!bounds %3!lidx!", - #else - "\364\316\370\342\355", - "\365\316\366!", - #endif - seqsize(8,4) - seqsize(4,3) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!load.i!", - "const.alt %1!load.s.pri %2!bounds %3!lidx!", - #else - "\363\316\370\342\355", - "\376\316\366!", - #endif - seqsize(8,4) - seqsize(4,3) - }, - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!load.i!", - "addr.alt %1!load.s.pri %2!lidx!", - #else - "\364\370\342\355", - "\365\366!", - #endif - seqsize(7,3) - seqsize(3,2) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!load.i!", - "const.alt %1!load.s.pri %2!lidx!", - #else - "\363\370\342\355", - "\376\366!", - #endif - seqsize(7,3) - seqsize(3,2) - }, -#endif - /* loading from array, not "cell" shifted */ - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!load.i!", - "addr.alt %1!load.s.pri %2!bounds %3!lidx.b %4!", - #else - "\364\316\327\302\341\342\355", - "\365\316\366\367\335", - #endif - seqsize(8,4) - seqsize(4,4) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!load.i!", - "const.alt %1!load.s.pri %2!bounds %3!lidx.b %4!", - #else - "\363\316\327\302\341\342\355", - "\376\316\366\367\335", - #endif - seqsize(8,4) - seqsize(4,4) - }, - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!load.i!", - "addr.alt %1!load.s.pri %2!lidx.b %3!", - #else - "\364\327\256\241\271\342\355", - "\365\366\367\256", - #endif - seqsize(7,3) - seqsize(3,3) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!load.i!", - "const.alt %1!load.s.pri %2!lidx.b %3!", - #else - "\363\327\256\241\271\342\355", - "\376\366\367\256", - #endif - seqsize(7,3) - seqsize(3,3) - }, -#if !defined BIT16 - /* array index calculation for storing a value, "cell" aligned */ - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!", - "addr.alt %1!load.s.pri %2!bounds %3!idxaddr!", - #else - "\364\316\370", - "\365\316\322\235\237", - #endif - seqsize(7,4) - seqsize(4,3) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!", - "const.alt %1!load.s.pri %2!bounds %3!idxaddr!", - #else - "\363\316\370", - "\376\316\322\235\237", - #endif - seqsize(7,4) - seqsize(4,3) - }, - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!", - "addr.alt %1!load.s.pri %2!idxaddr!", - #else - "\364\370", - "\365\322\235\237", - #endif - seqsize(6,3) - seqsize(3,2) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!", - "const.alt %1!load.s.pri %2!idxaddr!", - #else - "\363\370", - "\376\322\235\237", - #endif - seqsize(6,3) - seqsize(3,2) - }, -#endif - /* array index calculation for storing a value, not "cell" packed */ - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!", - "addr.alt %1!load.s.pri %2!bounds %3!idxaddr.b %4!", - #else - "\364\316\327\302\341", - "\365\316\322\265\367\335", - #endif - seqsize(7,4) - seqsize(4,4) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!", - "const.alt %1!load.s.pri %2!bounds %3!idxaddr.b %4!", - #else - "\363\316\327\302\341", - "\376\316\322\265\367\335", - #endif - seqsize(7,4) - seqsize(4,4) - }, - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!", - "addr.alt %1!load.s.pri %2!idxaddr.b %3!", - #else - "\364\327\256\241\271", - "\365\322\265\367\256", - #endif - seqsize(6,3) - seqsize(3,3) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!", - "const.alt %1!load.s.pri %2!idxaddr.b %3!", - #else - "\363\327\256\241\271", - "\376\322\265\367\256", - #endif - seqsize(6,3) - seqsize(3,3) - }, -#if !defined BIT16 - /* the shorter array indexing sequences, see above for comments */ - { - #ifdef SCPACK - "shl.c.pri 2!pop.alt!add!loadi!", - "pop.alt!lidx!", - #else - "\370\217\355", - "\241\366!", - #endif - seqsize(4,1) - seqsize(2,0) - }, - { - #ifdef SCPACK - "shl.c.pri 2!pop.alt!add!", - "pop.alt!idxaddr!", - #else - "\370", - "\241\322\235\237", - #endif - seqsize(3,1) - seqsize(2,0) - }, -#endif - { - #ifdef SCPACK - "shl.c.pri %1!pop.alt!add!loadi!", - "pop.alt!lidx.b %1!", - #else - "\314\225\241\271\217\355", - "\241\366\367\202", - #endif - seqsize(4,1) - seqsize(2,1) - }, - { - #ifdef SCPACK - "shl.c.pri %1!pop.alt!add!", - "pop.alt!idxaddr.b %1!", - #else - "\314\225\241\271", - "\241\322\265\367\202", - #endif - seqsize(3,1) - seqsize(2,1) - }, - /* For packed arrays, there is another case (packed arrays - * do not take advantage of the LIDX or IDXADDR instructions). - * addr.pri n1 addr.alt n1 - * push.pri load.s.pri n2 - * load.s.pri n2 bounds n3 - * bounds n3 - - * pop.alt - - * - * Notes (additional cases): - * 1. instruction addr.pri can also be const.pri (for - * global arrays) - * 2. the bounds instruction can be absent, but that - * case is already handled (see #1#) - */ - { - #ifdef SCPACK - "addr.pri %1!push.pri!load.s.pri %2!bounds %3!pop.alt!", - "addr.alt %1!load.s.pri %2!bounds %3!", - #else - "\364\316\241", - "\365\316", - #endif - seqsize(5,3) - seqsize(3,3) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!load.s.pri %2!bounds %3!pop.alt!", - "const.alt %1!load.s.pri %2!bounds %3!", - #else - "\363\316\241", - "\376\316", - #endif - seqsize(5,3) - seqsize(3,3) - }, - /* Declaration of simple variables often follows the sequence: - * ;$lcl ;$lcl - * stack -4 push.c - * const.pri ;$exp - * stor.s.pri - - * ;$exp - - */ - { - #ifdef SCPACK - ";$lcl %1 %2!stack -4!const.pri %3!stor.s.pri %2!;$exp!", - ";$lcl %1 %2!push.c %3!;$exp!", - #else - "\224lcl\332\227ack -4!\233\206\256\227or\222\230\252", - "\224lcl\332\331\256\252", - #endif - seqsize(3,3) - seqsize(1,1) - }, - { - #ifdef SCPACK - ";$lcl %1 %2!stack -4!zero.pri!stor.s.pri %2!;$exp!", - ";$lcl %1 %2!push.c 0!;$exp!", - #else - "\224lcl\332\227ack -4!\373\227or\222\230\252", - "\224lcl\332\331 0!\252", - #endif - seqsize(3,2) - seqsize(1,1) - }, - /* During a calculation, the intermediate result must sometimes - * be moved from PRI to ALT, like in: - * push.pri move.alt - * load.s.pri n1 load.s.pri n1 - * pop.alt - - * - * The above also accurs for "load.pri" and for "const.pri", - * so add another two cases. - */ - { - #ifdef SCPACK - "push.pri!load.s.pri %1!pop.alt!", - "move.alt!load.s.pri %1!", - #else - "\244\333\241", - "\306\333", - #endif - seqsize(3,1) - seqsize(2,1) - }, - { - #ifdef SCPACK - "push.pri!load.pri %1!pop.alt!", - "move.alt!load.pri %1!", - #else - "\244\311\241", - "\306\311", - #endif - seqsize(3,1) - seqsize(2,1) - }, - { - #ifdef SCPACK - "push.pri!const.pri %1!pop.alt!", - "move.alt!const.pri %1!", - #else - "\244\330\241", - "\306\330", - #endif - seqsize(3,1) - seqsize(2,1) - }, - { - #ifdef SCPACK - "push.pri!zero.pri!pop.alt!", - "move.alt!zero.pri!", - #else - "\244\373\241", - "\306\373", - #endif - seqsize(3,0) - seqsize(2,0) - }, - /* saving PRI and then loading from its address - * occurs when indexing a multi-dimensional array - */ - { - #ifdef SCPACK - "push.pri!load.i!pop.alt!", - "move.alt!load.i!", - #else - "\244\342i\266", - "\306\342\355", - #endif - seqsize(3,0) - seqsize(2,0) - }, - /* An even simpler PUSH/POP optimization (occurs in - * switch statements): - * push.pri move.alt - * pop.alt - - */ - { - #ifdef SCPACK - "push.pri!pop.alt!", - "move.alt!", - #else - "\244\241", - "\306", - #endif - seqsize(2,0) - seqsize(1,0) - }, - /* Some simple arithmetic sequences - */ - { - #ifdef SCPACK - "move.alt!load.s.pri %1!add!", - "load.s.alt %1!add!", - #else - "\306\333\271", - "\375\271", - #endif - seqsize(3,1) - seqsize(2,1) - }, - { - #ifdef SCPACK - "move.alt!load.pri %1!add!", - "load.alt %1!add!", - #else - "\306\311\271", - "\374\271", - #endif - seqsize(3,1) - seqsize(2,1) - }, - { - #ifdef SCPACK - "move.alt!const.pri %1!add!", - "const.alt %1!add!", - #else - "\306\330\271", - "\356\271", - #endif - seqsize(3,1) - seqsize(2,1) - }, - { - #ifdef SCPACK - "move.alt!load.s.pri %1!sub.alt!", - "load.s.alt %1!sub!", - #else - "\306\333sub\223", - "\375sub!", - #endif - seqsize(3,1) - seqsize(2,1) - }, - { - #ifdef SCPACK - "move.alt!load.pri %1!sub.alt!", - "load.alt %1!sub!", - #else - "\306\311sub\223", - "\374sub!", - #endif - seqsize(3,1) - seqsize(2,1) - }, - { - #ifdef SCPACK - "move.alt!const.pri %1!sub.alt!", - "const.alt %1!sub!", - #else - "\306\330sub\223", - "\356sub!", - #endif - seqsize(3,1) - seqsize(2,1) - }, - /* User-defined operators first load the operands into registers and - * then have them pushed onto the stack. This can give rise to sequences - * like: - * const.pri n1 push.c n1 - * const.alt n2 push.c n2 - * push.pri - - * push.alt - - * A similar sequence occurs with the two PUSH.pri/alt instructions inverted. - * The first, second, or both CONST.pri/alt instructions can also be - * LOAD.pri/alt. - * This gives 2 x 4 cases. - */ - { - #ifdef SCPACK - "const.pri %1!const.alt %2!push.pri!push.alt!", - "push.c %1!push.c %2!", - #else - "\330\233\304\244\354", - "\331\202\331\221", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "const.pri %1!const.alt %2!push.alt!push.pri!", - "push.c %2!push.c %1!", - #else - "\330\233\304\354\244", - "\331\221\331\202", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "const.pri %1!load.alt %2!push.pri!push.alt!", - "push.c %1!push %2!", - #else - "\330\362\244\354", - "\331\202\216\221", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "const.pri %1!load.alt %2!push.alt!push.pri!", - "push %2!push.c %1!", - #else - "\330\362\354\244", - "\216\221\331\202", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.pri %1!const.alt %2!push.pri!push.alt!", - "push %1!push.c %2!", - #else - "\311\233\304\244\354", - "\216\202\331\221", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.pri %1!const.alt %2!push.alt!push.pri!", - "push.c %2!push %1!", - #else - "\311\233\304\354\244", - "\331\221\216\202", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.pri %1!load.alt %2!push.pri!push.alt!", - "push %1!push %2!", - #else - "\311\362\244\354", - "\216\202\216\221", - #endif - seqsize(4,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "load.pri %1!load.alt %2!push.alt!push.pri!", - "push %2!push %1!", - #else - "\311\362\354\244", - "\216\221\216\202", - #endif - seqsize(4,2) - seqsize(2,2) - }, - /* Function calls (parameters are passed on the stack) - * load.s.pri n1 push.s n1 - * push.pri - - * -------------------------------------- - * load.pri n1 push n1 - * push.pri - - * -------------------------------------- - * const.pri n1 push.c n1 - * push.pri - - * -------------------------------------- - * zero.pri push.c 0 - * push.pri - - * -------------------------------------- - * addr.pri n1 push.adr n1 - * push.pri - - * - * However, PRI must not be needed after this instruction - * if this shortcut is used. Check for the ;$par comment. - */ - { - #ifdef SCPACK - "load.s.pri %1!push.pri!;$par!", - "push.s %1!;$par!", - #else - "\226\264\255", - "\216\222\202\255", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "load.pri %1!push.pri!;$par!", - "push %1!;$par!", - #else - "\217\264\255", - "\216\202\255", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "const.pri %1!push.pri!;$par!", - "push.c %1!;$par!", - #else - "\233\264\255", - "\331\202\255", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "zero.pri!push.pri!;$par!", - "push.c 0!;$par!", - #else - "\373\244\255", - "\331 0!\255", - #endif - seqsize(2,0) - seqsize(1,1) - }, - { - #ifdef SCPACK - "addr.pri %1!push.pri!;$par!", - "push.adr %1!;$par!", - #else - "\265\264\255", - "\216\326\202\255", - #endif - seqsize(2,1) - seqsize(1,1) - }, - /* References with a default value generate new cells on the heap - * dynamically. That code often ends with: - * move.pri push.alt - * push.pri - - */ - { - #ifdef SCPACK - "move.pri!push.pri!", - "push.alt!", - #else - "\300\236\244", - "\354", - #endif - seqsize(2,0) - seqsize(1,0) - }, - /* Simple arithmetic operations on constants. Noteworthy is the - * subtraction of a constant, since it is converted to the addition - * of the inverse value. - * const.alt n1 add.c n1 - * add - - * -------------------------------------- - * const.alt n1 add.c -n1 - * sub - - * -------------------------------------- - * const.alt n1 smul.c n1 - * smul - - * -------------------------------------- - * const.alt n1 eq.c.pri n1 - * eq - - */ - { - #ifdef SCPACK - "const.alt %1!add!", - "add.c %1!", - #else - "\356\271", - "\235\242\202", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "const.alt %1!sub!", - "add.c -%1!", - #else - "\356sub!", - "\235\242 -\201", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "const.alt %1!smul!", - "smul.c %1!", - #else - "\356smul!", - "smu\307\202", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "const.alt %1!eq!", - "eq.c.pri %1!", - #else - "\356\325", - "\262\242\225", - #endif - seqsize(2,1) - seqsize(1,1) - }, - /* Some operations use the alternative subtraction operation --these - * can also be optimized. - * const.pri n1 load.s.pri n2 - * load.s.alt n2 add.c -n1 - * sub.alt - - * -------------------------------------- - * const.pri n1 load.pri n2 - * load.alt n2 add.c -n1 - * sub.alt - - */ - { - #ifdef SCPACK - "const.pri %1!load.s.alt %2!sub.alt!", - "load.s.pri %2!add.c -%1!", - #else - "\330\226\304sub\223", - "\246\235\242 -\201", - #endif - seqsize(3,2) - seqsize(2,2) - }, - { - #ifdef SCPACK - "const.pri %1!load.alt %2!sub.alt!", - "load.pri %2!add.c -%1!", - #else - "\330\362sub\223", - "\334\235\242 -\201", - #endif - seqsize(3,2) - seqsize(2,2) - }, - /* With arrays indexed with constants that come from enumerations, it happens - * multiple add.c opcodes follow in sequence. - * add.c n1 add.c n1+n2 - * add.c n2 - - */ - { - #ifdef SCPACK - "add.c %1!add.c %2!", - "add.c %1+%2!", - #else - "\235\242\202\235\242\221", - "\235\242\267+%2!", - #endif - seqsize(2,2) - seqsize(1,1) - }, - /* Compare and jump - * eq jneq n1 - * jzer n1 - - * -------------------------------------- - * eq jeq n1 - * jnz n1 - - * -------------------------------------- - * neq jeq n1 - * jzer n1 - - * -------------------------------------- - * neq jneq n1 - * jnz n1 - - * Compares followed by jzer occur much more - * often than compares followed with jnz. So we - * take the easy route here. - * less jgeq n1 - * jzer n1 - - * -------------------------------------- - * leq jgrtr n1 - * jzer n1 - - * -------------------------------------- - * grtr jleq n1 - * jzer n1 - - * -------------------------------------- - * geq jless n1 - * jzer n1 - - * -------------------------------------- - * sless jsgeq n1 - * jzer n1 - - * -------------------------------------- - * sleq jsgrtr n1 - * jzer n1 - - * -------------------------------------- - * sgrtr jsleq n1 - * jzer n1 - - * -------------------------------------- - * sgeq jsless n1 - * jzer n1 - - */ - { - #ifdef SCPACK - "eq!jzer %1!", - "jneq %1!", - #else - "\325\323", - "jn\357", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "eq!jnz %1!", - "jeq %1!", - #else - "\325jnz\202", - "j\357", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "neq!jzer %1!", - "jeq %1!", - #else - "n\325\323", - "j\357", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "neq!jnz %1!", - "jneq %1!", - #else - "n\325jnz\202", - "jn\357", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "less!jzer %1!", - "jgeq %1!", - #else - "l\352!\323", - "jg\357", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "leq!jzer %1!", - "jgrtr %1!", - #else - "l\325\323", - "jg\353r\202", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "grtr!jzer %1!", - "jleq %1!", - #else - "g\353\237\323", - "jl\357", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "geq!jzer %1!", - "jless %1!", - #else - "g\325\323", - "jl\352\202", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "sless!jzer %1!", - "jsgeq %1!", - #else - "\372!\323", - "j\320\357", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "sleq!jzer %1!", - "jsgrtr %1!", - #else - "\321\325\323", - "j\371r\202", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "sgrtr!jzer %1!", - "jsleq %1!", - #else - "\371\237\323", - "j\321\357", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "sgeq!jzer %1!", - "jsless %1!", - #else - "\320\325\323", - "j\372\202", - #endif - seqsize(2,1) - seqsize(1,1) - }, - /* Test for zero (common case, especially for strings) - * E.g. the test expression of: "for (i=0; str{i}!=0; ++i)" - * - * zero.alt jzer n1 - * jeq n1 - - * -------------------------------------- - * zero.alt jnz n1 - * jneq n1 - - */ - { - #ifdef SCPACK - "zero.alt!jeq %1!", - "jzer %1!", - #else - "\340\223j\357", - "\323", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "zero.alt!jneq %1!", - "jnz %1!", - #else - "\340\223jn\357", - "jnz\202", - #endif - seqsize(2,1) - seqsize(1,1) - }, - /* Incrementing and decrementing leaves a value in - * in PRI which may not be used (for example, as the - * third expression in a "for" loop). - * inc n1 inc n1 ; ++n - * load.pri n1 ;$exp - * ;$exp - - * -------------------------------------- - * load.pri n1 inc n1 ; n++, e.g. "for (n=0; n<10; n++)" - * inc n1 ;$exp - * ;$exp - - * Plus the varieties for stack relative increments - * and decrements. - */ - { - #ifdef SCPACK - "inc %1!load.pri %1!;$exp!", - "inc %1!;$exp!", - #else - "inc\202\311\252", - "inc\301", - #endif - seqsize(2,2) - seqsize(1,1) - }, - { - #ifdef SCPACK - "load.pri %1!inc %1!;$exp!", - "inc %1!;$exp!", - #else - "\311inc\301", - "inc\301", - #endif - seqsize(2,2) - seqsize(1,1) - }, - { - #ifdef SCPACK - "inc.s %1!load.s.pri %1!;$exp!", - "inc.s %1!;$exp!", - #else - "inc\222\202\333\252", - "inc\222\301", - #endif - seqsize(2,2) - seqsize(1,1) - }, - { - #ifdef SCPACK - "load.s.pri %1!inc.s %1!;$exp!", - "inc.s %1!;$exp!", - #else - "\333inc\222\301", - "inc\222\301", - #endif - seqsize(2,2) - seqsize(1,1) - }, - { - #ifdef SCPACK - "dec %1!load.pri %1!;$exp!", - "dec %1!;$exp!", - #else - "dec\202\311\252", - "dec\301", - #endif - seqsize(2,2) - seqsize(1,1) - }, - { - #ifdef SCPACK - "load.pri %1!dec %1!;$exp!", - "dec %1!;$exp!", - #else - "\311dec\301", - "dec\301", - #endif - seqsize(2,2) - seqsize(1,1) - }, - { - #ifdef SCPACK - "dec.s %1!load.s.pri %1!;$exp!", - "dec.s %1!;$exp!", - #else - "dec\222\202\333\252", - "dec\222\301", - #endif - seqsize(2,2) - seqsize(1,1) - }, - { - #ifdef SCPACK - "load.s.pri %1!dec.s %1!;$exp!", - "dec.s %1!;$exp!", - #else - "\333dec\222\301", - "dec\222\301", - #endif - seqsize(2,2) - seqsize(1,1) - }, - /* ??? the same (increments and decrements) for references */ - /* Loading the constant zero has a special opcode. - * When storing zero in memory, the value of PRI must not be later on. - * const.pri 0 zero n1 - * stor.pri n1 ;$exp - * ;$exp - - * -------------------------------------- - * const.pri 0 zero.s n1 - * stor.s.pri n1 ;$exp - * ;$exp - - * -------------------------------------- - * zero.pri zero n1 - * stor.pri n1 ;$exp - * ;$exp - - * -------------------------------------- - * zero.pri zero.s n1 - * stor.s.pri n1 ;$exp - * ;$exp - - * -------------------------------------- - * const.pri 0 zero.pri - * -------------------------------------- - * const.alt 0 zero.alt - * The last two alternatives save more memory than they save - * time, but anyway... - */ - { - #ifdef SCPACK - "const.pri 0!stor.pri %1!;$exp!", - "zero %1!;$exp!", - #else - "\233\206 0!\227or\225\252", - "\340\301", - #endif - seqsize(2,2) - seqsize(1,1) - }, - { - #ifdef SCPACK - "const.pri 0!stor.s.pri %1!;$exp!", - "zero.s %1!;$exp!", - #else - "\233\206 0!\227or\222\225\252", - "\340\222\301", - #endif - seqsize(2,2) - seqsize(1,1) - }, - { - #ifdef SCPACK - "zero.pri!stor.pri %1!;$exp!", - "zero %1!;$exp!", - #else - "\373\227or\225\252", - "\340\301", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "zero.pri!stor.s.pri %1!;$exp!", - "zero.s %1!;$exp!", - #else - "\373\227or\222\225\252", - "\340\222\301", - #endif - seqsize(2,1) - seqsize(1,1) - }, - { - #ifdef SCPACK - "const.pri 0!", - "zero.pri!", - #else - "\233\206 0!", - "\373", - #endif - seqsize(1,1) - seqsize(1,0) - }, - { - #ifdef SCPACK - "const.alt 0!", - "zero.alt!", - #else - "\233\212 0!", - "\340\223", - #endif - seqsize(1,1) - seqsize(1,0) - }, - - /* ------------------ */ - /* Macro instructions */ - /* ------------------ */ - - { "", "", 0 }, /* separator, so optimizer can stop before generating macro opcodes */ - - /* optimizing the calling of native functions (which always have a parameter - * count pushed before, and the stack pointer restored afterwards - */ - { - #ifdef SCPACK - "push.c %1!sysreq.c %2!stack %3!", //note: %3 == %1 + 4 - "sysreq.n %2 %1!", - #else - "\331\202sysr\262\242\221\227ack\256", - "sysr\262.n\220\202", - #endif - seqsize(3,3) - seqsize(1,2) - }, - /* ----- */ - /* Functions with many parameters with the same "type" have sequences like: - * push.c n1 push3.c n1 n2 n3 - * ;$par ;$par - * push.c n2 - - * ;$par - - * push.c n3 - - * ;$par - - * etc. etc. - * - * Similar sequences occur with PUSH, PUSH.s and PUSHADDR - */ - { - #ifdef SCPACK - "push.c %1!;$par!push.c %2!;$par!push.c %3!;$par!push.c %4!;$par!push.c %5!", - "push5.c %1 %2 %3 %4 %5!", - #else - "\331\336\242\345\242\256\257\242\335\257\242\2035!", - "\2165\242\343\245\302\2035!", - #endif - seqsize(5,5) - seqsize(1,5) - }, - { - #ifdef SCPACK - "push.c %1!;$par!push.c %2!;$par!push.c %3!;$par!push.c %4!", - "push4.c %1 %2 %3 %4!", - #else - "\331\336\242\345\242\256\257\242\335", - "\2164\242\343\245\335", - #endif - seqsize(4,4) - seqsize(1,4) - }, - { - #ifdef SCPACK - "push.c %1!;$par!push.c %2!;$par!push.c %3!", - "push3.c %1 %2 %3!", - #else - "\331\336\242\345\242\256", - "\2163\242\343\256", - #endif - seqsize(3,3) - seqsize(1,3) - }, - { - #ifdef SCPACK - "push.c %1!;$par!push.c %2!", - "push2.c %1 %2!", - #else - "\331\336\242\221", - "\2162\242\332", - #endif - seqsize(2,2) - seqsize(1,2) - }, - /* ----- */ - { - #ifdef SCPACK - "push %1!;$par!push %2!;$par!push %3!;$par!push %4!;$par!push %5!", - "push5 %1 %2 %3 %4 %5!", - #else - "\216\336\345\256\257\335\257\2035!", - "\2165\343\245\302\2035!", - #endif - seqsize(5,5) - seqsize(1,5) - }, - { - #ifdef SCPACK - "push %1!;$par!push %2!;$par!push %3!;$par!push %4!", - "push4 %1 %2 %3 %4!", - #else - "\216\336\345\256\257\335", - "\2164\343\245\335", - #endif - seqsize(4,4) - seqsize(1,4) - }, - { - #ifdef SCPACK - "push %1!;$par!push %2!;$par!push %3!", - "push3 %1 %2 %3!", - #else - "\216\336\345\256", - "\2163\343\256", - #endif - seqsize(3,3) - seqsize(1,3) - }, - { - #ifdef SCPACK - "push %1!;$par!push %2!", - "push2 %1 %2!", - #else - "\216\336\221", - "\2162\332", - #endif - seqsize(2,2) - seqsize(1,2) - }, - /* ----- */ - { - #ifdef SCPACK - "push.s %1!;$par!push.s %2!;$par!push.s %3!;$par!push.s %4!;$par!push.s %5!", - "push5.s %1 %2 %3 %4 %5!", - #else - "\216\222\336\222\345\222\256\257\222\335\257\222\2035!", - "\2165\222\343\245\302\2035!", - #endif - seqsize(5,5) - seqsize(1,5) - }, - { - #ifdef SCPACK - "push.s %1!;$par!push.s %2!;$par!push.s %3!;$par!push.s %4!", - "push4.s %1 %2 %3 %4!", - #else - "\216\222\336\222\345\222\256\257\222\335", - "\2164\222\343\245\335", - #endif - seqsize(4,4) - seqsize(1,4) - }, - { - #ifdef SCPACK - "push.s %1!;$par!push.s %2!;$par!push.s %3!", - "push3.s %1 %2 %3!", - #else - "\216\222\336\222\345\222\256", - "\2163\222\343\256", - #endif - seqsize(3,3) - seqsize(1,3) - }, - { - #ifdef SCPACK - "push.s %1!;$par!push.s %2!", - "push2.s %1 %2!", - #else - "\216\222\336\222\221", - "\2162\222\332", - #endif - seqsize(2,2) - seqsize(1,2) - }, - /* ----- */ - { - #ifdef SCPACK - "push.adr %1!;$par!push.adr %2!;$par!push.adr %3!;$par!push.adr %4!;$par!push.adr %5!", - "push5.adr %1 %2 %3 %4 %5!", - #else - "\216\326\336\326\345\326\256\257\326\335\257\326\2035!", - "\2165\326\343\245\302\2035!", - #endif - seqsize(5,5) - seqsize(1,5) - }, - { - #ifdef SCPACK - "push.adr %1!;$par!push.adr %2!;$par!push.adr %3!;$par!push.adr %4!", - "push4.adr %1 %2 %3 %4!", - #else - "\216\326\336\326\345\326\256\257\326\335", - "\2164\326\343\245\335", - #endif - seqsize(4,4) - seqsize(1,4) - }, - { - #ifdef SCPACK - "push.adr %1!;$par!push.adr %2!;$par!push.adr %3!", - "push3.adr %1 %2 %3!", - #else - "\216\326\336\326\345\326\256", - "\2163\326\343\256", - #endif - seqsize(3,3) - seqsize(1,3) - }, - { - #ifdef SCPACK - "push.adr %1!;$par!push.adr %2!", - "push2.adr %1 %2!", - #else - "\216\326\336\326\221", - "\2162\326\332", - #endif - seqsize(2,2) - seqsize(1,2) - }, - /* Loading two registers at a time - * load.pri n1 load.both n1 n2 - * load.alt n2 - - * -------------------------------------- - * load.alt n2 load.both n1 n2 - * load.pri n1 - - * -------------------------------------- - * load.s.pri n1 load.s.both n1 n2 - * load.s.alt n2 - - * -------------------------------------- - * load.s.alt n2 load.s.both n1 n2 - * load.s.pri n1 - - */ - { - #ifdef SCPACK - "load.pri %1!load.alt %2!", - "load.both %1 %2!", - #else - "\311\362", - "\342\275th\332", - #endif - seqsize(2,2) - seqsize(1,2) - }, - { - #ifdef SCPACK - "load.alt %2!load.pri %1!", - "load.both %1 %2!", - #else - "\362\311", - "\342\275th\332", - #endif - seqsize(2,2) - seqsize(1,2) - }, - { - #ifdef SCPACK - "load.s.pri %1!load.s.alt %2!", - "load.s.both %1 %2!", - #else - "\333\226\304", - "\226.\275th\332", - #endif - seqsize(2,2) - seqsize(1,2) - }, - { - #ifdef SCPACK - "load.s.alt %2!load.s.pri %1!", - "load.s.both %1 %2!", - #else - "\226\304\333", - "\226.\275th\332", - #endif - seqsize(2,2) - seqsize(1,2) - }, - /* Loading two registers and then pushing them occurs with user operators - * load.both n1 n2 push2 n1 n2 - * push.pri - - * push.alt - - * -------------------------------------- - * load.s.both n1 n2 push2.s n1 n2 - * push.pri - - * push.alt - - */ - { - #ifdef SCPACK - "load.both %1 %2!push.pri!push.alt!", - "push2 %1 %2!", - #else - "\342\275th\332\244\354", - "\2162\332", - #endif - seqsize(3,2) - seqsize(1,2) - }, - { - #ifdef SCPACK - "load.s.both %1 %2!push.pri!push.alt!", - "push2.s %1 %2!", - #else - "\226.\275th\332\244\354", - "\2162\222\332", - #endif - seqsize(3,2) - seqsize(1,2) - }, - /* Load a constant in a variable - * const.pri n1 const n2 n1 - * stor.pri n2 - - * -------------------------------------- - * const.pri n1 const.s n2 n1 - * stor.s.pri n2 - - */ - { - #ifdef SCPACK - "const.pri %1!stor.pri %2!", - "const %2 %1!", - #else - "\330\227or\230", - "\233\220\202", - #endif - seqsize(2,2) - seqsize(1,2) - }, - { - #ifdef SCPACK - "const.pri %1!stor.s.pri %2!", - "const.s %2 %1!", - #else - "\330\227or\222\230", - "\233\222\220\202", - #endif - seqsize(2,2) - seqsize(1,2) - }, - /* ----- */ - { NULL, NULL, 0 } -}; diff --git a/sourcepawn/compiler/sc7.cpp b/sourcepawn/compiler/sc7.cpp deleted file mode 100644 index 99763956..00000000 --- a/sourcepawn/compiler/sc7.cpp +++ /dev/null @@ -1,703 +0,0 @@ -/* Pawn compiler - Staging buffer and optimizer - * - * The staging buffer - * ------------------ - * The staging buffer allows buffered output of generated code, deletion - * of redundant code, optimization by a tinkering process and reversing - * the ouput of evaluated expressions (which is used for the reversed - * evaluation of arguments in functions). - * Initially, stgwrite() writes to the file directly, but after a call to - * stgset(TRUE), output is redirected to the buffer. After a call to - * stgset(FALSE), stgwrite()'s output is directed to the file again. Thus - * only one routine is used for writing to the output, which can be - * buffered output or direct output. - * - * staging buffer variables: stgbuf - the buffer - * stgidx - current index in the staging buffer - * staging - if true, write to the staging buffer; - * if false, write to file directly. - * - * The peephole optimizer uses a dual "pipeline". The staging buffer (described - * above) gets optimized for each expression or sub-expression in a function - * call. The peephole optimizer is recursive, but it does not span multiple - * sub-expressions. However, the data gets written to a second buffer that - * behaves much like the staging buffer. This second buffer gathers all - * optimized strings from the staging buffer for a complete expression. The - * peephole optmizer then runs over this second buffer to find optimzations - * across function parameter boundaries. - * - * - * Copyright (c) ITB CompuPhase, 1997-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include -#include /* for atoi() */ -#include -#include -#if defined FORTIFY - #include -#endif -#include "sc.h" - -#if defined _MSC_VER - #pragma warning(push) - #pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */ -#endif - -#include - -#if defined _MSC_VER - #pragma warning(pop) -#endif - -static int stgstring(char *start,char *end); -static void stgopt(char *start,char *end,int (*outputfunc)(char *str)); - - -#define sSTG_GROW 512 -#define sSTG_MAX 20480 - -static char *stgbuf=NULL; -static int stgmax=0; /* current size of the staging buffer */ - -static char *stgpipe=NULL; -static int pipemax=0; /* current size of the stage pipe, a second staging buffer */ -static int pipeidx=0; - -#define CHECK_STGBUFFER(index) if ((int)(index)>=stgmax) grow_stgbuffer(&stgbuf, &stgmax, (index)+1) -#define CHECK_STGPIPE(index) if ((int)(index)>=pipemax) grow_stgbuffer(&stgpipe, &pipemax, (index)+1) - -static void grow_stgbuffer(char **buffer, int *curmax, int requiredsize) -{ - char *p; - int clear= (*buffer==NULL); /* if previously none, empty buffer explicitly */ - - assert(*curmaxsSTG_MAX) - error(FATAL_ERROR_OOM); - *curmax=requiredsize+sSTG_GROW; - if (*buffer!=NULL) - p=(char *)realloc(*buffer,*curmax*sizeof(char)); - else - p=(char *)malloc(*curmax*sizeof(char)); - if (p==NULL) - error(FATAL_ERROR_OOM); - *buffer=p; - if (clear) - **buffer='\0'; -} - -void stgbuffer_cleanup(void) -{ - if (stgbuf!=NULL) { - free(stgbuf); - stgbuf=NULL; - stgmax=0; - } /* if */ - if (stgpipe!=NULL) { - free(stgpipe); - stgpipe=NULL; - pipemax=0; - pipeidx=0; - } /* if */ -} - -/* the variables "stgidx" and "staging" are declared in "scvars.c" */ - -/* stgmark - * - * Copies a mark into the staging buffer. At this moment there are three - * possible marks: - * sSTARTREORDER identifies the beginning of a series of expression - * strings that must be written to the output file in - * reordered order - * sENDREORDER identifies the end of 'reverse evaluation' - * sEXPRSTART + idx only valid within a block that is evaluated in - * reordered order, it identifies the start of an - * expression; the "idx" value is the argument position - * - * Global references: stgidx (altered) - * stgbuf (altered) - * staging (referred to only) - */ -void stgmark(char mark) -{ - if (staging) { - CHECK_STGBUFFER(stgidx); - stgbuf[stgidx++]=mark; - } /* if */ -} - -static int rebuffer(char *str) -{ - if (sc_status==statWRITE) { - if (pipeidx>=2 && stgpipe[pipeidx-1]=='\0' && stgpipe[pipeidx-2]!='\n') - pipeidx-=1; /* overwrite last '\0' */ - while (*str!='\0') { /* copy to staging buffer */ - CHECK_STGPIPE(pipeidx); - stgpipe[pipeidx++]=*str++; - } /* while */ - CHECK_STGPIPE(pipeidx); - stgpipe[pipeidx++]='\0'; - } /* if */ - return TRUE; -} - -static int filewrite(char *str) -{ - if (sc_status==statWRITE) - return pc_writeasm(outf,str); - return TRUE; -} - -/* stgwrite - * - * Writes the string "st" to the staging buffer or to the output file. In the - * case of writing to the staging buffer, the terminating byte of zero is - * copied too, but... the optimizer can only work on complete lines (not on - * fractions of it. Therefore if the string is staged, if the last character - * written to the buffer is a '\0' and the previous-to-last is not a '\n', - * the string is concatenated to the last string in the buffer (the '\0' is - * overwritten). This also means an '\n' used in the middle of a string isn't - * recognized and could give wrong results with the optimizer. - * Even when writing to the output file directly, all strings are buffered - * until a whole line is complete. - * - * Global references: stgidx (altered) - * stgbuf (altered) - * staging (referred to only) - */ -void stgwrite(const char *st) -{ - int len; - - if (staging) { - assert(stgidx==0 || stgbuf!=NULL); /* staging buffer must be valid if there is (apparently) something in it */ - if (stgidx>=2 && stgbuf[stgidx-1]=='\0' && stgbuf[stgidx-2]!='\n') - stgidx-=1; /* overwrite last '\0' */ - while (*st!='\0') { /* copy to staging buffer */ - CHECK_STGBUFFER(stgidx); - stgbuf[stgidx++]=*st++; - } /* while */ - CHECK_STGBUFFER(stgidx); - stgbuf[stgidx++]='\0'; - } else { - len=(stgbuf!=NULL) ? strlen(stgbuf) : 0; - CHECK_STGBUFFER(len+strlen(st)+1); - strcat(stgbuf,st); - len=strlen(stgbuf); - if (len>0 && stgbuf[len-1]=='\n') { - filewrite(stgbuf); - stgbuf[0]='\0'; - } /* if */ - } /* if */ -} - -/* stgout - * - * Writes the staging buffer to the output file via stgstring() (for - * reversing expressions in the buffer) and stgopt() (for optimizing). It - * resets "stgidx". - * - * Global references: stgidx (altered) - * stgbuf (referred to only) - * staging (referred to only) - */ -void stgout(int index) -{ - int reordered=0; - int idx; - - if (!staging) - return; - assert(pipeidx==0); - - /* first pass: sub-expressions */ - if (sc_status==statWRITE) - reordered=stgstring(&stgbuf[index],&stgbuf[stgidx]); - stgidx=index; - - /* second pass: optimize the buffer created in the first pass */ - if (sc_status==statWRITE) { - if (reordered) { - stgopt(stgpipe,stgpipe+pipeidx,filewrite); - } else { - /* there is no sense in re-optimizing if the order of the sub-expressions - * did not change; so output directly - */ - for (idx=0; idx=0) - stack[arg].end=start-1; /* finish previous argument */ - arg=(unsigned char)*start - sEXPRSTART; - stack[arg].start=start+1; - if (arg>=argc) - argc=arg+1; - } /* if */ - start++; - } else { - start+=strlen(start)+1; - } /* if */ - } /* switch */ - } while (nest); /* enddo */ - if (arg>=0) - stack[arg].end=start-1; /* finish previous argument */ - while (argc>0) { - argc--; - stgstring(stack[argc].start,stack[argc].end); - } /* while */ - free(stack); - } else { - ptr=start; - while (ptr0) - filewrite(stgbuf); - } /* if */ - stgbuf[0]='\0'; -} - -/* phopt_init - * Initialize all sequence strings of the peehole optimizer. The strings - * are embedded in the .EXE file in compressed format, here we expand - * them (and allocate memory for the sequences). - */ -static SEQUENCE *sequences; - -int phopt_init(void) -{ - int number, i, len; - char str[160]; - - /* count number of sequences */ - for (number=0; sequences_cmp[number].find!=NULL; number++) - /* nothing */; - number++; /* include an item for the NULL terminator */ - - if ((sequences=(SEQUENCE*)malloc(number * sizeof(SEQUENCE)))==NULL) - return FALSE; - - /* pre-initialize all to NULL (in case of failure) */ - for (i=0; i (PAWN_CELL_SIZE/4) * MAX_OPT_CAT - #define MAX_ALIAS sNAMEMAX -#else - #define MAX_ALIAS (PAWN_CELL_SIZE/4) * MAX_OPT_CAT -#endif - -static int matchsequence(char *start,char *end,char *pattern, - char symbols[MAX_OPT_VARS][MAX_ALIAS+1], - int *match_length) -{ - int var,i; - char str[MAX_ALIAS+1]; - char *start_org=start; - cell value; - char *ptr; - - *match_length=0; - for (var=0; var=end) - return FALSE; - switch (*pattern) { - case '%': /* new "symbol" */ - pattern++; - assert(isdigit(*pattern)); - var=atoi(pattern) - 1; - assert(var>=0 && var=0 && var=0 && var0) { /* delete a section */ - memmove(dest,dest+offset,dest_length-offset); - memset(dest+dest_length-offset,0xcc,offset); /* not needed, but for cleanlyness */ - } else if (offset<0) { /* insert a section */ - memmove(dest-offset, dest, dest_length); - } /* if */ - memcpy(dest, replace, repl_length); -} - -/* stgopt - * - * Optimizes the staging buffer by checking for series of instructions that - * can be coded more compact. The routine expects the lines in the staging - * buffer to be separated with '\n' and '\0' characters. - * - * The longest sequences should probably be checked first. - */ - -static void stgopt(char *start,char *end,int (*outputfunc)(char *str)) -{ - char symbols[MAX_OPT_VARS][MAX_ALIAS+1]; - int seq,match_length,repl_length; - int matches; - char *debut=start; /* save original start of the buffer */ - - assert(sequences!=NULL); - /* do not match anything if debug-level is maximum */ - if (pc_optimize>sOPTIMIZE_NONE && sc_status==statWRITE) { - do { - matches=0; - start=debut; - while (start=0); - if (*sequences[seq].find=='\0') { - if (pc_optimize==sOPTIMIZE_NOMACRO) { - break; /* don't look further */ - } else { - seq++; /* continue with next string */ - continue; - } /* if */ - } /* if */ - if (matchsequence(start,end,sequences[seq].find,symbols,&match_length)) { - char *replace=replacesequence(sequences[seq].replace,symbols,&repl_length); - /* If the replacement is bigger than the original section, we may need - * to "grow" the staging buffer. This is quite complex, due to the - * re-ordering of expressions that can also happen in the staging - * buffer. In addition, it should not happen: the peephole optimizer - * must replace sequences with *shorter* sequences, not longer ones. - * So, I simply forbid sequences that are longer than the ones they - * are meant to replace. - */ - assert(match_length>=repl_length); - if (match_length>=repl_length) { - strreplace(start,replace,match_length,repl_length,(int)(end-start)); - end-=match_length-repl_length; - free(replace); - code_idx-=sequences[seq].savesize; - seq=0; /* restart search for matches */ - matches++; - } else { - /* actually, we should never get here (match_length0); - } /* if (pc_optimize>sOPTIMIZE_NONE && sc_status==statWRITE) */ - - for (start=debut; start -#include -#include "sc.h" - -#define STACKSIZE 16 - -int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]) -{ - unsigned char stack[STACKSIZE]; - short c, top = 0; - int len; - - assert(maxlen > 0); - len = 1; /* already 1 byte for '\0' */ - for (;;) { - - /* Pop byte from stack or read byte from the input string */ - if (top) - c = stack[--top]; - else if ((c = *(unsigned char *)source++) == '\0') - break; - - /* Push pair on stack or output byte to the output string */ - if (c > 127) { - assert(top+2 <= STACKSIZE); - stack[top++] = pairtable[c-128][1]; - stack[top++] = pairtable[c-128][0]; - } - else { - len++; - if (maxlen > 1) { /* reserve one byte for the '\0' */ - *dest++ = (char)c; - maxlen--; - } - } - } - *dest = '\0'; - return len; /* return number of bytes decoded */ -} - -#if 0 /*for testing*/ -#include "sc5.scp" - -int main (int argc, char **argv) -{ - int i; - char str[128]; - - for (i=0; i<58; i++) { - strexpand(str, errmsg[i], sizeof str, SCPACK_TABLE); - printf("%s", str); - } /* for */ - return 0; -} -#endif - diff --git a/sourcepawn/compiler/sci18n.cpp b/sourcepawn/compiler/sci18n.cpp deleted file mode 100644 index 980dcbdc..00000000 --- a/sourcepawn/compiler/sci18n.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/* Codepage translation to Unicode, and UTF-8 support - * - * The translation is based on codepage mapping files that are distributed - * by the Unicode consortium, see ftp://ftp.unicode.org/Public/MAPPINGS/. - * - * Character sets with a maximum of 256 codes are translated via a lookup - * table (these are Single-Byte Character Sets). Character sets like Shift-JIS - * with single-byte characters and multi-byte characters (introduced by a - * leader byte) are split into two tables: the 256-entry lookup table for - * the single-byte characters and an extended table for the multi-byte - * characters. The extended table is allocated dynamically; the lookup table - * is allocated statically, so loading SBCS tables cannot fail (if the tables - * themselves are valid, of course). - * - * Copyright (c) ITB CompuPhase, 2004-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include -#include -#include -#include -#include "sc.h" - -#if !defined TRUE - #define FALSE 0 - #define TRUE 1 -#endif -#if !defined _MAX_PATH - #define _MAX_PATH 250 -#endif -#if !defined DIRSEP_CHAR - #if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ - #define DIRSEP_CHAR '/' - #elif defined macintosh - #define DIRSEP_CHAR ':' - #else - #define DIRSEP_CHAR '\\' - #endif -#endif - -#if !defined ELEMENTS - #define ELEMENTS(array) (sizeof(array) / sizeof(array[0])) -#endif - -#if !defined NO_CODEPAGE - -#if !defined MAXCODEPAGE - #define MAXCODEPAGE 12 /* typically "cp" + 4 digits + ".txt" */ -#endif -#define INVALID 0xffffu /* 0xffff and 0xfffe are invalid Unicode characters */ -#define LEADBYTE 0xfffeu - -struct wordpair { - unsigned short index; - wchar_t code; -}; -static char cprootpath[_MAX_PATH] = { DIRSEP_CHAR, '\0' }; -static wchar_t bytetable[256]; -static struct wordpair *wordtable = NULL; -static unsigned wordtablesize = 0; -static unsigned wordtabletop = 0; - - -/* read in a line delimited by '\r' or '\n'; do NOT store the '\r' or '\n' into - * the string and ignore empty lines - * returns 1 for success and 0 for failure - */ -static int cp_readline(FILE *fp,char *string,size_t size) -{ - size_t count=0; - int c; - assert(size>1); - while ((c=fgetc(fp))!=EOF && count0) /* '\r' or '\n' ends a string */ - break; - /* if count==0, the line started with a '\r' or '\n', or perhaps line - * ends in the file are '\r\n' and we read and stopped on the '\r' of - * the preceding line - */ - } else { - string[count++]=(char)c; - } /* if */ - } /* while */ - string[count]='\0'; - return count>0; -} - -/* cp_path() sets the directory where all codepage files must be found (if - * the parameter to cp_set() specifies a full path, that is used instead). - * The path is specified into two parts: root and directory; the full path - * for the codepage direcory is just the concatenation of the two, with a - * directory separator in between. The directory is given in two parts, - * because often a program already retrieves its "home" directory and the - * codepages are most conveniently stored in a subdirectory of this home - * directory. - */ -int cp_path(const char *root, const char *directory) -{ - size_t len1,len2; - int add_slash1,add_slash2; - - len1= (root!=NULL) ? strlen(root) : 0; - add_slash1= (len1==0 || root[len1-1]!=DIRSEP_CHAR); - len2= (directory!=NULL) ? strlen(directory) : 0; - add_slash2= (len2>0 && root[len2-1]!=DIRSEP_CHAR); - if (len1+add_slash1+len2+add_slash2>=(_MAX_PATH-MAXCODEPAGE)) - return FALSE; /* full filename may not fit */ - if (root!=NULL) - strcpy(cprootpath,root); - if (add_slash1) { - assert(len1==0 || cprootpath[len1]=='\0'); - cprootpath[len1]=DIRSEP_CHAR; - cprootpath[len1+1]='\0'; - } /* if */ - if (directory!=NULL) - strcat(cprootpath,directory); - if (add_slash2) { - assert(cprootpath[len1+add_slash1+len2]=='\0'); - cprootpath[len1+add_slash1+len2]=DIRSEP_CHAR; - cprootpath[len1+add_slash1+len2+1]='\0'; - } /* if */ - cp_set(NULL); /* start with a "linear" table (no translation) */ - return TRUE; -} - -/* cp_set() loads a codepage from a file. The name parameter may be a - * filename (including a full path) or it may be a partial codepage name. - * If the name parameter is NULL, the codepage is cleared to be a "linear" - * table (no translation). - * The following files are attempted to open (where specifies the - * value of the parameter): - * - * / - * /.txt - * /cp - * /cp.txt - */ -int cp_set(const char *name) -{ - char filename[_MAX_PATH]; - FILE *fp=NULL; - unsigned index; - - /* for name==NULL, set up an identity table */ - if (name==NULL || *name=='\0') { - if (wordtable!=NULL) { - free(wordtable); - wordtable=NULL; - wordtablesize=0; - wordtabletop=0; - } /* if */ - for (index=0; indexMAXCODEPAGE) - return 0; - assert(strlen(name)+strlen(cprootpath)<_MAX_PATH); - strcpy(filename,cprootpath); - strcat(filename,name); - fp=fopen(filename,"rt"); - } /* if */ - if (fp==NULL) { - /* try opening the file in the "root path" for codepages, with a ".txt" extension */ - if (strlen(name)+4>=MAXCODEPAGE) - return 0; - assert(strlen(filename)+4<_MAX_PATH); - strcat(filename,".txt"); - fp=fopen(filename,"rt"); - } /* if */ - if (fp==NULL) { - /* try opening the file in the "root path" for codepages, with "cp" prefixed before the name */ - if (strlen(name)+2>MAXCODEPAGE) - return 0; - assert(2+strlen(name)+strlen(cprootpath)<_MAX_PATH); - strcpy(filename,cprootpath); - strcat(filename,"cp"); - strcat(filename,name); - fp=fopen(filename,"rt"); - } /* if */ - if (fp==NULL) { - /* try opening the file in the "root path" for codepages, with "cp" prefixed an ".txt" appended */ - if (strlen(name)+2+4>MAXCODEPAGE) - return 0; - assert(strlen(filename)+4<_MAX_PATH); - strcat(filename,".txt"); - fp=fopen(filename,"rt"); - } /* if */ - if (fp==NULL) - return FALSE; /* all failed */ - - /* clear the tables */ - for (index=0; index0 && wordtable!=NULL)); - if (wordtable!=NULL) { - free(wordtable); - wordtable=NULL; - wordtablesize=0; - wordtabletop=0; - } /* if */ - - /* read in the table */ - while (cp_readline(fp,filename,sizeof filename)) { - char *ptr; - if ((ptr=strchr(filename,'#'))!=NULL) - *ptr='\0'; /* strip of comment */ - for (ptr=filename; *ptr>0 && *ptr<' '; ptr++) - /* nothing */; /* skip leading whitespace */ - if (*ptr!='\0') { - /* content on line */ - unsigned code=LEADBYTE; - int num=sscanf(ptr,"%i %i",&index,&code); - /* if sscanf() returns 1 and the index is in range 0..255, then the - * code is a DBCS lead byte; if sscanf() returns 2 and index>=256, this - * is a double byte pair (lead byte + follower) - */ - if (num>=1 && index<256) { - bytetable[index]=(wchar_t)code; - } else if (num==2 && index>=256 && index=wordtablesize) { - /* grow the list */ - int newsize; - struct wordpair *newblock; - newsize= (wordtablesize==0) ? 128 : 2*wordtablesize; - newblock=(struct wordpair *)malloc(newsize*sizeof(*wordtable)); - if (newblock!=NULL) { - memcpy(newblock,wordtable,wordtabletop*sizeof(*wordtable)); - free(wordtable); - wordtable=newblock; - wordtablesize=newsize; - } /* if */ - } /* if */ - if (wordtabletop0 && (unsigned)wordtable[pos-1].index>index) { - wordtable[pos]=wordtable[pos-1]; - pos--; - } /* while */ - wordtable[pos].index=(unsigned short)index; - wordtable[pos].code=(wchar_t)code; - } /* if */ - } /* if */ - } /* if */ - } /* while */ - - fclose(fp); - return TRUE; -} - -cell cp_translate(const unsigned char *string,const unsigned char **endptr) -{ - wchar_t result; - - result=bytetable[*string++]; - /* check whether this is a leader code */ - if ((unsigned)result==LEADBYTE && wordtable!=NULL) { - /* look up the code via binary search */ - int low,high,mid; - unsigned short index=(unsigned short)(((*(string-1)) << 8) | *string); - string++; - assert(wordtabletop>0); - low=0; - high=wordtabletop-1; - while (lowwordtable[mid].index) - low=mid+1; - else - high=mid; - } /* while */ - assert(low==high); - if (wordtable[low].index==index) - result=wordtable[low].code; - } /* if */ - - if (endptr!=NULL) - *endptr=string; - return (cell)result; -} - -#endif /* NO_CODEPAGE */ - -#if !defined NO_UTF8 -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=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 - -int scan_utf8(void *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,resetpos); - 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 */ -} diff --git a/sourcepawn/compiler/sclinux.h b/sourcepawn/compiler/sclinux.h deleted file mode 100644 index 1ec9405c..00000000 --- a/sourcepawn/compiler/sclinux.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Things needed to compile under linux. - * - * Should be reworked totally to use GNU's 'configure' - */ -#ifndef SCLINUX_H -#define SCLINUX_H - -/* getchar() is not a 'cool' replacement for MSDOS getch: Linux/unix depends on the features activated or not about the - * controlling terminal's tty. This means that ioctl(2) calls must be performed, for instance to have the controlling - * terminal tty's in 'raw' mode, if we want to be able to fetch a single character. This also means that everything must - * be put back correctly when the function ends. See GETCH.C for an implementation. - * - * For interactive use of SRUN/SDBG if would be much better to use GNU's readline package: the user would be able to - * have a complete emacs/vi like line editing system. - */ -#include "getch.h" - -/* - * WinWorld wants '\'. Unices do not. - */ -#define DIRECTORY_SEP_CHAR '/' -#define DIRECTORY_SEP_STR "/" - -/* - * SC assumes that a computer is Little Endian unless told otherwise. It uses - * (and defines) the macros BYTE_ORDER and BIG_ENDIAN. - * For Linux, we must overrule these settings with those defined in glibc. - */ -#if !defined __BYTE_ORDER -# if defined EMSCRIPTEN -# include -# else -# include -# endif -#endif - -#if defined __OpenBSD__ || defined __FreeBSD__ || defined __APPLE__ -# define __BYTE_ORDER BYTE_ORDER -# define __LITTLE_ENDIAN LITTLE_ENDIAN -# define __BIG_ENDIAN BIG_ENDIAN -#endif - -#if !defined __BYTE_ORDER -# error "Can't figure computer byte order (__BYTE_ORDER macro not found)" -#endif - -#endif /* SCLINUX_H */ diff --git a/sourcepawn/compiler/sclist.cpp b/sourcepawn/compiler/sclist.cpp deleted file mode 100644 index bcf7192b..00000000 --- a/sourcepawn/compiler/sclist.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/* Pawn compiler - maintenance of various lists - * - * o Name list (aliases) - * o Include path list - * o Macro definitions (text substitutions) - * o Documentation tags and automatic listings - * o Debug strings - * - * Copyright (c) ITB CompuPhase, 2001-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include -#include -#include -#include "sc.h" -#include "lstring.h" - -#if defined FORTIFY - #include -#endif - -/* a "private" implementation of strdup(), so that porting - * to other memory allocators becomes easier. - * By Søren Hannibal. - */ -char* duplicatestring(const char* sourcestring) -{ - char* result=(char*)malloc(strlen(sourcestring)+1); - strcpy(result,sourcestring); - return result; -} - - -static stringpair *insert_stringpair(stringpair *root,const char *first,const char *second,int matchlength) -{ - stringpair *cur,*pred; - - assert(root!=NULL); - assert(first!=NULL); - assert(second!=NULL); - /* create a new node, and check whether all is okay */ - if ((cur=(stringpair*)malloc(sizeof(stringpair)))==NULL) - return NULL; - cur->first=duplicatestring(first); - cur->second=duplicatestring(second); - cur->matchlength=matchlength; - cur->documentation=NULL; - if (cur->first==NULL || cur->second==NULL) { - if (cur->first!=NULL) - free(cur->first); - if (cur->second!=NULL) - free(cur->second); - free(cur); - return NULL; - } /* if */ - /* link the node to the tree, find the position */ - for (pred=root; pred->next!=NULL && strcmp(pred->next->first,first)<0; pred=pred->next) - /* nothing */; - cur->next=pred->next; - pred->next=cur; - return cur; -} - -static void delete_stringpairtable(stringpair *root) -{ - stringpair *cur, *next; - - assert(root!=NULL); - cur=root->next; - while (cur!=NULL) { - next=cur->next; - assert(cur->first!=NULL); - assert(cur->second!=NULL); - free(cur->first); - free(cur->second); - free(cur); - cur=next; - } /* while */ - memset(root,0,sizeof(stringpair)); -} - -static stringpair *find_stringpair(stringpair *cur,char *first,int matchlength) -{ - int result=0; - - assert(matchlength>0); /* the function cannot handle zero-length comparison */ - assert(first!=NULL); - while (cur!=NULL && result<=0) { - result=(int)*cur->first - (int)*first; - if (result==0 && matchlength==cur->matchlength) { - result=strncmp(cur->first,first,matchlength); - if (result==0) - return cur; - } /* if */ - cur=cur->next; - } /* while */ - return NULL; -} - -static int delete_stringpair(stringpair *root,stringpair *item) -{ - stringpair *cur; - - assert(root!=NULL); - cur=root; - while (cur->next!=NULL) { - if (cur->next==item) { - cur->next=item->next; /* unlink from list */ - assert(item->first!=NULL); - assert(item->second!=NULL); - free(item->first); - free(item->second); - free(item); - return TRUE; - } /* if */ - cur=cur->next; - } /* while */ - return FALSE; -} - -/* ----- string list functions ----------------------------------- */ -static stringlist *insert_string(stringlist *root,const char *string) -{ - stringlist *cur; - - assert(string!=NULL); - if ((cur=(stringlist*)malloc(sizeof(stringlist)))==NULL) - error(103); /* insufficient memory (fatal error) */ - if ((cur->line=duplicatestring(string))==NULL) - error(103); /* insufficient memory (fatal error) */ - cur->next=NULL; - if (root->tail) - root->tail->next=cur; - else - root->next=cur; - root->tail=cur; - return cur; -} - -static char *get_string(stringlist *root,int index) -{ - stringlist *cur; - - assert(root!=NULL); - cur=root->next; - while (cur!=NULL && index-->0) - cur=cur->next; - if (cur!=NULL) { - assert(cur->line!=NULL); - return cur->line; - } /* if */ - return NULL; -} - -static int delete_string(stringlist *root,int index) -{ - stringlist *cur,*item; - - assert(root!=NULL); - for (cur=root; cur->next!=NULL && index>0; cur=cur->next,index--) - /* nothing */; - if (cur->next!=NULL) { - item=cur->next; - if (root->tail == cur->next) - root->tail = cur; - cur->next=item->next; /* unlink from list */ - assert(item->line!=NULL); - free(item->line); - free(item); - return TRUE; - } /* if */ - return FALSE; -} - -void delete_stringtable(stringlist *root) -{ - stringlist *cur,*next; - - assert(root!=NULL); - cur=root->next; - while (cur!=NULL) { - next=cur->next; - assert(cur->line!=NULL); - free(cur->line); - free(cur); - cur=next; - } /* while */ - memset(root,0,sizeof(stringlist)); -} - - -/* ----- alias table --------------------------------------------- */ -static stringpair alias_tab = {NULL, NULL, NULL}; /* alias table */ - -stringpair *insert_alias(char *name,char *alias) -{ - stringpair *cur; - - assert(name!=NULL); - assert(strlen(name)<=sNAMEMAX); - assert(alias!=NULL); - assert(strlen(alias)<=sNAMEMAX); - if ((cur=insert_stringpair(&alias_tab,name,alias,strlen(name)))==NULL) - error(103); /* insufficient memory (fatal error) */ - return cur; -} - -int lookup_alias(char *target,char *name) -{ - stringpair *cur=find_stringpair(alias_tab.next,name,strlen(name)); - if (cur!=NULL) { - assert(strlen(cur->second)<=sNAMEMAX); - strcpy(target,cur->second); - } /* if */ - return cur!=NULL; -} - -void delete_aliastable(void) -{ - delete_stringpairtable(&alias_tab); -} - -/* ----- include paths list -------------------------------------- */ -static stringlist includepaths; /* directory list for include files */ - -stringlist *insert_path(char *path) -{ - return insert_string(&includepaths,path); -} - -char *get_path(int index) -{ - return get_string(&includepaths,index); -} - -void delete_pathtable(void) -{ - delete_stringtable(&includepaths); - assert(includepaths.next==NULL); -} - - -/* ----- text substitution patterns ------------------------------ */ -#if !defined NO_DEFINE - -static stringpair substpair = { NULL, NULL, NULL}; /* list of substitution pairs */ - -static stringpair *substindex['z'-PUBLIC_CHAR+1]; /* quick index to first character */ -static void adjustindex(char c) -{ - stringpair *cur; - assert((c>='A' && c<='Z') || (c>='a' && c<='z') || c=='_' || c==PUBLIC_CHAR); - assert(PUBLIC_CHAR<'A' && 'A'<'_' && '_'<'z'); - - for (cur=substpair.next; cur!=NULL && cur->first[0]!=c; cur=cur->next) - /* nothing */; - substindex[(int)c-PUBLIC_CHAR]=cur; -} - -stringpair *insert_subst(const char *pattern,const char *substitution,int prefixlen) -{ - stringpair *cur; - - assert(pattern!=NULL); - assert(substitution!=NULL); - if ((cur=insert_stringpair(&substpair,pattern,substitution,prefixlen))==NULL) - error(103); /* insufficient memory (fatal error) */ - adjustindex(*pattern); - - if (pc_deprecate!=NULL) { - assert(cur!=NULL); - cur->flags|=flgDEPRECATED; - if (sc_status==statWRITE) { - if (cur->documentation!=NULL) { - free(cur->documentation); - cur->documentation=NULL; - } /* if */ - cur->documentation=pc_deprecate; - } else { - free(pc_deprecate); - } /* if */ - pc_deprecate=NULL; - } else { - cur->flags = 0; - cur->documentation = NULL; - } /* if */ - - return cur; -} - -stringpair *find_subst(char *name,int length) -{ - stringpair *item; - assert(name!=NULL); - assert(length>0); - assert((*name>='A' && *name<='Z') || (*name>='a' && *name<='z') || *name=='_' || *name==PUBLIC_CHAR); - item=substindex[(int)*name-PUBLIC_CHAR]; - if (item!=NULL) - item=find_stringpair(item,name,length); - - if (item && (item->flags & flgDEPRECATED) != 0) - { - static char macro[128]; - const char *msg = (item->documentation != NULL) ? item->documentation : ""; - strlcpy(macro, item->first, sizeof(macro)); - - /* If macro contains an opening parentheses and a percent sign, then assume that - * it takes arguments and remove them from the warning message. - */ - char *rem; - if ((rem = strchr(macro, '(')) != NULL && strchr(macro, '%') > rem) - { - *rem = '\0'; - } - - error(234, macro, msg); /* deprecated (macro/constant) */ - } - return item; -} - -int delete_subst(char *name,int length) -{ - stringpair *item; - assert(name!=NULL); - assert(length>0); - assert((*name>='A' && *name<='Z') || (*name>='a' && *name<='z') || *name=='_' || *name==PUBLIC_CHAR); - item=substindex[(int)*name-PUBLIC_CHAR]; - if (item!=NULL) - item=find_stringpair(item,name,length); - if (item==NULL) - return FALSE; - if (item->documentation) - { - free(item->documentation); - item->documentation=NULL; - } - delete_stringpair(&substpair,item); - adjustindex(*name); - return TRUE; -} - -void delete_substtable(void) -{ - int i; - delete_stringpairtable(&substpair); - for (i=0; i=199901L - #define __STDC_FORMAT_MACROS - #define __STDC_CONSTANT_MACROS - #include /* automatically includes stdint.h */ -#elif (defined _MSC_VER || defined __BORLANDC__) && (defined _I64_MAX || defined HAVE_I64) - #define PRId64 "I64d" - #define PRIx64 "I64x" -#else - #define PRId64 "lld" - #define PRIx64 "llx" -#endif -#if PAWN_CELL_SIZE==64 - #define PRIdC PRId64 - #define PRIxC PRIx64 -#elif PAWN_CELL_SIZE==32 - #define PRIdC "ld" - #define PRIxC "lx" -#else - #define PRIdC "d" - #define PRIxC "x" -#endif - -static stringlist dbgstrings; - -stringlist *insert_dbgfile(const char *filename) -{ - - if (sc_status==statWRITE && (sc_debug & sSYMBOLIC)!=0) { - char string[_MAX_PATH+40]; - assert(filename!=NULL); - assert(strlen(filename)+400) - linenr--; /* line numbers are zero-based in the debug information */ - sprintf(string,"L:%" PRIxC " %x",code_idx,linenr); - return insert_string(&dbgstrings,string); - } /* if */ - return NULL; -} - -stringlist *insert_dbgsymbol(symbol *sym) -{ - if (sc_status==statWRITE && (sc_debug & sSYMBOLIC)!=0) { - char string[2*sNAMEMAX+128]; - char symname[2*sNAMEMAX+16]; - - funcdisplayname(symname,sym->name); - /* address tag:name codestart codeend ident vclass [tag:dim ...] */ - if (sym->ident==iFUNCTN) { - sprintf(string,"S:%" PRIxC " %x:%s %" PRIxC " %" PRIxC " %x %x", - sym->addr,sym->tag,symname,sym->addr,sym->codeaddr,sym->ident,sym->vclass); - } else { - sprintf(string,"S:%" PRIxC " %x:%s %" PRIxC " %" PRIxC " %x %x", - sym->addr,sym->tag,symname,sym->codeaddr,code_idx,sym->ident,sym->vclass); - } /* if */ - if (sym->ident==iARRAY || sym->ident==iREFARRAY) { - #if !defined NDEBUG - int count=sym->dim.array.level; - #endif - symbol *sub; - strcat(string," [ "); - for (sub=sym; sub!=NULL; sub=finddepend(sub)) { - assert(sub->dim.array.level==count--); - sprintf(string+strlen(string),"%x:%x ",sub->x.tags.index,sub->dim.array.length); - } /* for */ - strcat(string,"]"); - } /* if */ - - return insert_string(&dbgstrings,string); - } /* if */ - return NULL; -} - -stringlist *get_dbgstrings() -{ - return &dbgstrings; -} - -char *get_dbgstring(int index) -{ - return get_string(&dbgstrings,index); -} - -void delete_dbgstringtable(void) -{ - delete_stringtable(&dbgstrings); - assert(dbgstrings.next==NULL); -} diff --git a/sourcepawn/compiler/scmemfil.cpp b/sourcepawn/compiler/scmemfil.cpp deleted file mode 100644 index 59eb3875..00000000 --- a/sourcepawn/compiler/scmemfil.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* Pawn compiler - * - * Routines to maintain a "text file" in memory. - * - * Copyright (c) ITB CompuPhase, 2003-2006 - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the - * use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ - -#include -#include -#include -#include -#include "memfile.h" - -#if defined FORTIFY - #include -#endif - -#include "sc.h" - -MEMFILE *mfcreate(const char *filename) -{ - return memfile_creat(filename, 4096); -} - -void mfclose(MEMFILE *mf) -{ - memfile_destroy(mf); -} - -int mfdump(MEMFILE *mf) -{ - FILE *fp; - int okay; - - assert(mf!=NULL); - /* create the file */ - fp=fopen(mf->name, "wb"); - if (fp==NULL) - return 0; - - okay=1; - okay = okay & (fwrite(mf->base, mf->usedoffs, 1, fp)==(size_t)mf->usedoffs); - - fclose(fp); - return okay; -} - -long mflength(const MEMFILE *mf) -{ - return mf->usedoffs; -} - -long mfseek(MEMFILE *mf,long offset,int whence) -{ - long length; - - assert(mf!=NULL); - if (mf->usedoffs == 0) - return 0L; /* early exit: not a single byte in the file */ - - /* find the size of the memory file */ - length=mflength(mf); - - /* convert the offset to an absolute position */ - switch (whence) { - case SEEK_SET: - break; - case SEEK_CUR: - offset+=mf->offs; - break; - case SEEK_END: - assert(offset<=0); - offset+=length; - break; - } /* switch */ - - /* clamp to the file length limit */ - if (offset<0) - offset=0; - else if (offset>length) - offset=length; - - /* set new position and return it */ - memfile_seek(mf, offset); - - return offset; -} - -unsigned int mfwrite(MEMFILE *mf,const unsigned char *buffer,unsigned int size) -{ - return (memfile_write(mf, buffer, size) ? size : 0); -} - -unsigned int mfread(MEMFILE *mf,unsigned char *buffer,unsigned int size) -{ - return memfile_read(mf, buffer, size); -} - -char *mfgets(MEMFILE *mf,char *string,unsigned int size) -{ - char *ptr; - unsigned int read; - long seek; - - assert(mf!=NULL); - - read=mfread(mf,(unsigned char *)string,size); - if (read==0) - return NULL; - seek=0L; - - /* make sure that the string is zero-terminated */ - assert(read<=size); - if (read -#include -#include -#include -#include - -#if UINT_MAX > 0xFFFFU - #define MAXSIZE 1024*1024L -#else - #define MAXSIZE UINT_MAX /* Input file buffer size */ -#endif -#define HASHSIZE 8192 /* Hash table size, power of 2 */ -#define THRESHOLD 3 /* Increase for speed, min 3 */ - -#define START_TOKEN "#ifdef SCPACK" /* start reading the buffer here */ -#define NAME_TOKEN "#define SCPACK_TABLE" -#define SEP_TOKEN "#define SCPACK_SEPARATOR" -#define TERM_TOKEN "#define SCPACK_TERMINATOR" -#define TEMPFILE "~SCPACK.TMP" -static char tablename[32+1] = "scpack_table"; -static char separator[16]=","; -static char terminator[16]=""; - -int compress(unsigned char *buffer, unsigned buffersize, unsigned char pairtable[128][2]) -{ - unsigned char *left, *right, *count; - unsigned char a, b, bestcount; - unsigned i, j, index, bestindex, code=128; - - /* Dynamically allocate buffers and check for errors */ - left = (unsigned char *)malloc(HASHSIZE); - right = (unsigned char *)malloc(HASHSIZE); - count = (unsigned char *)malloc(HASHSIZE); - if (left==NULL || right==NULL || count==NULL) { - printf("Error allocating memory\n"); - exit(1); - } - - /* Check for errors */ - for (i=0; i 127) { - printf("This program works only on text files (7-bit ASCII)\n"); - exit(1); - } - - memset(pairtable, 0, 128*2*sizeof(char)); - - do { /* Replace frequent pairs with bytes 128..255 */ - - /* Enter counts of all byte pairs into hash table */ - memset(count,0,HASHSIZE); - for (i=0; i bestcount) { - bestcount = count[i]; - bestindex = i; - } - } - - /* Compress if enough occurrences of pair */ - if (bestcount >= THRESHOLD) { - - /* Add pair to table using code as index */ - a = pairtable[code-128][0] = left[bestindex]; - b = pairtable[code-128][1] = right[bestindex]; - - /* Replace all pair occurrences with unused byte */ - for (i=0, j=0; i= 128 || *bufptr == '"' || *bufptr == '\\') - fprintf(output, "\\%03o", *bufptr); - else - fprintf(output, "%c", *bufptr); - bufptr++; - } /* while */ - fprintf(output, "\""); - needseparator = 1; - bufptr++; /* skip '\0' */ - } /* while */ - fprintf(output, "%s\n",terminator); - bufptr++; - - /* skip the input file until the #endif section */ - while (fgets(str,sizeof str,input)!=NULL) { - if (strmatch(str,"#endif",NULL)) { - fprintf(output,"%s",str); - break; /* done */ - } /* if */ - } /* while */ - } /* while - !feof(input) */ -} - -static void usage(void) -{ - printf("Usage: scpack [output file]\n"); - exit(1); -} - -int main(int argc, char **argv) -{ - FILE *in, *out; - unsigned char *buffer; - unsigned buffersize, orgbuffersize; - unsigned char pairtable[128][2]; - - if (argc < 2 || argc > 3) - usage(); - if ((in=fopen(argv[1],"rt"))==NULL) { - printf("SCPACK: error opening input %s\n",argv[1]); - usage(); - } /* if */ - if (argc == 2) { - if ((out=fopen(TEMPFILE,"wt"))==NULL) { - printf("SCPACK: error opening temporary file %s\n",TEMPFILE); - usage(); - } /* if */ - } else { - if ((out=fopen(argv[2],"wt"))==NULL) { - printf("SCPACK: error opening output file %s\n",argv[2]); - usage(); - } /* if */ - } /* if */ - - buffer = (unsigned char *)malloc(MAXSIZE); - if (buffer == NULL) { - printf("SCPACK: error allocating memory\n"); - return 1; - } /* if */ - /* 1. read the buffer - * 2. compress the buffer - * 3. copy the file, insert the compressed buffer - */ - buffersize = readbuffer(in, buffer); - orgbuffersize = buffersize; - if (buffersize > 0) { - buffersize = compress(buffer, buffersize, pairtable); - writefile(in, out, buffer, buffersize, pairtable); - printf("SCPACK: compression ratio: %ld%% (%d -> %d)\n", - 100L-(100L*buffersize)/orgbuffersize, orgbuffersize, buffersize); - } else { - printf("SCPACK: no SCPACK section found, nothing to do\n"); - } /* if */ - fclose(out); - fclose(in); - /* let the new file replace the old file */ - if (buffersize == 0) { - if (argc == 2) - remove(TEMPFILE); - else - remove(argv[2]); - } else if (argc == 2) { - remove(argv[1]); - rename(TEMPFILE,argv[1]); - } /* if */ - return 0; -} diff --git a/sourcepawn/compiler/scstate.cpp b/sourcepawn/compiler/scstate.cpp deleted file mode 100644 index 8c772804..00000000 --- a/sourcepawn/compiler/scstate.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/* Pawn compiler - * - * Machine and state maintenance. - * - * Three lists are maintained here: - * - A list of automatons (state machines): these hold a name, a unique id - * (in the "index" field) and the memory address of a cell that holds the - * current state of the automaton (in the "value" field). - * - A list of states for each automaton: a name, an automaton id (in the - * "index" field) and a unique id for the state (unique in the automaton; - * states belonging to different automatons may have the same id). - * - A list of state combinations. Each function may belong to a set of states. - * This list assigns a unique id to the combination of the automaton and all - * states. - * - * For a function/variable that has states, there is a fourth list, which is - * attached to the "symbol" structure. This list contains the code label (in - * the "name" field, only for functions), the id of the state combinations (the - * state list id; it is stored in the "index" field) and the code address at - * which the function starts. The latter is currently unused. - * - * At the start of the compiled code, a set of stub functions is generated. - * Each stub function looks up the value of the "state selector" value for the - * automaton, and goes with a "switch" instruction to the start address of the - * function. This happens in SC4.C. - * - * - * Copyright (c) ITB CompuPhase, 2005-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include -#include -#include -#include -#include "sc.h" -#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ - #include -#endif - -#if defined FORTIFY - #include -#endif - -typedef struct s_statelist { - struct s_statelist *next; - int *states; /* list of states in this combination */ - int numstates; /* number of items in the above list */ - int fsa; /* automaton id */ - int listid; /* unique id for this combination list */ -} statelist; - -static statelist statelist_tab = { NULL, NULL, 0, 0, 0}; /* state combinations table */ - - -static constvalue *find_automaton(const char *name,int *last) -{ - constvalue *ptr; - - assert(last!=NULL); - *last=0; - ptr=sc_automaton_tab.next; - while (ptr!=NULL) { - if (strcmp(name,ptr->name)==0) - return ptr; - if (ptr->index>*last) - *last=ptr->index; - ptr=ptr->next; - } /* while */ - return NULL; -} - -constvalue *automaton_add(const char *name) -{ - constvalue *ptr; - int last; - - assert(strlen(name)name)); - ptr=find_automaton(name,&last); - if (ptr==NULL) { - assert(last+1 <= SHRT_MAX); - ptr=append_constval(&sc_automaton_tab,name,(cell)0,(short)(last+1)); - } /* if */ - return ptr; -} - -constvalue *automaton_find(const char *name) -{ - int last; - return find_automaton(name,&last); -} - -constvalue *automaton_findid(int id) -{ - constvalue *ptr; - for (ptr=sc_automaton_tab.next; ptr!=NULL && ptr->index!=id; ptr=ptr->next) - /* nothing */; - return ptr; -} - - -static constvalue *find_state(const char *name,int fsa,int *last) -{ - constvalue *ptr; - - assert(last!=NULL); - *last=0; - ptr=sc_state_tab.next; - while (ptr!=NULL) { - if (ptr->index==fsa) { - if (strcmp(name,ptr->name)==0) - return ptr; - if ((int)ptr->value>*last) - *last=(int)ptr->value; - } /* if */ - ptr=ptr->next; - } /* while */ - return NULL; -} - -constvalue *state_add(const char *name,int fsa) -{ - constvalue *ptr; - int last; - - assert(strlen(name)name)); - ptr=find_state(name,fsa,&last); - if (ptr==NULL) { - assert(fsa <= SHRT_MAX); - ptr=append_constval(&sc_state_tab,name,(cell)(last+1),(short)fsa); - } /* if */ - return ptr; -} - -constvalue *state_find(const char *name,int fsa_id) -{ - int last; /* dummy */ - return find_state(name,fsa_id,&last); -} - -constvalue *state_findid(int id) -{ - constvalue *ptr; - for (ptr=sc_state_tab.next; ptr!=NULL && ptr->value!=id; ptr=ptr->next) - /* nothing */; - return ptr; -} - -void state_buildlist(int **list,int *listsize,int *count,int stateid) -{ - int idx; - - assert(list!=NULL); - assert(listsize!=NULL); - assert(*listsize>=0); - assert(count!=NULL); - assert(*count>=0); - assert(*count<=*listsize); - - if (*count==*listsize) { - /* To avoid constantly calling malloc(), the list is grown by 4 states at - * a time. - */ - *listsize+=4; - *list=(int*)realloc(*list,*listsize*sizeof(int)); - if (*list==NULL) - error(103); /* insufficient memory */ - } /* if */ - - /* find the insertion point (the list has to stay sorted) */ - for (idx=0; idx<*count && *list[idx]0); - assert(last!=NULL); - *last=0; - ptr=statelist_tab.next; - while (ptr!=NULL) { - if (ptr->listid>*last) - *last=ptr->listid; - if (ptr->fsa==fsa && ptr->numstates==count) { - /* compare all states */ - for (i=0; istates[i]==list[i]; i++) - /* nothing */; - if (i==count) - return ptr; - } /* if */ - ptr=ptr->next; - } /* while */ - return NULL; -} - -static statelist *state_getlist_ptr(int listid) -{ - statelist *ptr; - - assert(listid>0); - for (ptr=statelist_tab.next; ptr!=NULL && ptr->listid!=listid; ptr=ptr->next) - /* nothing */; - return ptr; -} - -int state_addlist(int *list,int count,int fsa) -{ - statelist *ptr; - int last; - - assert(list!=NULL); - assert(count>0); - ptr=state_findlist(list,count,fsa,&last); - if (ptr==NULL) { - if ((ptr=(statelist*)malloc(sizeof(statelist)))==NULL) - error(103); /* insufficient memory */ - if ((ptr->states=(int*)malloc(count*sizeof(int)))==NULL) { - free(ptr); - error(103); /* insufficient memory */ - } /* if */ - memcpy(ptr->states,list,count*sizeof(int)); - ptr->numstates=count; - ptr->fsa=fsa; - ptr->listid=last+1; - ptr->next=statelist_tab.next; - statelist_tab.next=ptr; - } /* if */ - assert(ptr!=NULL); - return ptr->listid; -} - -void state_deletetable(void) -{ - statelist *ptr; - - while (statelist_tab.next!=NULL) { - ptr=statelist_tab.next; - /* unlink first */ - statelist_tab.next=ptr->next; - /* then delete */ - assert(ptr->states!=NULL); - free(ptr->states); - free(ptr); - } /* while */ -} - -int state_getfsa(int listid) -{ - statelist *ptr; - - assert(listid>=0); - if (listid==0) - return -1; - - ptr=state_getlist_ptr(listid); - return (ptr!=NULL) ? ptr->fsa : -1; /* fsa 0 exists */ -} - -int state_count(int listid) -{ - statelist *ptr=state_getlist_ptr(listid); - if (ptr==NULL) - return 0; /* unknown list, no states in it */ - return ptr->numstates; -} - -int state_inlist(int listid,int state) -{ - statelist *ptr; - int i; - - ptr=state_getlist_ptr(listid); - if (ptr==NULL) - return FALSE; /* unknown list, state not in it */ - for (i=0; inumstates; i++) - if (ptr->states[i]==state) - return TRUE; - return FALSE; -} - -int state_listitem(int listid,int index) -{ - statelist *ptr; - - ptr=state_getlist_ptr(listid); - assert(ptr!=NULL); - assert(index>=0 && indexnumstates); - return ptr->states[index]; -} - -static int checkconflict(statelist *psrc,statelist *ptgt) -{ - int s,t; - - assert(psrc!=NULL); - assert(ptgt!=NULL); - for (s=0; snumstates; s++) - for (t=0; tnumstates; t++) - if (psrc->states[s]==ptgt->states[t]) - return 1; /* state conflict */ - return 0; -} - -/* This function searches whether one of the states in the list of statelist id's - * of a symbol exists in any other statelist id's of the same function; it also - * verifies that all definitions of the symbol are in the same automaton. - */ -void state_conflict(symbol *root) -{ - statelist *psrc,*ptgt; - constvalue *srcptr,*tgtptr; - symbol *sym; - - assert(root!=NULL); - for (sym=root->next; sym!=NULL; sym=sym->next) { - if (sym->parent!=NULL || sym->ident!=iFUNCTN) - continue; /* hierarchical data type or no function */ - if (sym->states==NULL) - continue; /* this function has no states */ - for (srcptr=sym->states->next; srcptr!=NULL; srcptr=srcptr->next) { - if (srcptr->index==-1) - continue; /* state list id -1 is a special case */ - psrc=state_getlist_ptr(srcptr->index); - assert(psrc!=NULL); - for (tgtptr=srcptr->next; tgtptr!=NULL; tgtptr=tgtptr->next) { - if (tgtptr->index==-1) - continue; /* state list id -1 is a special case */ - ptgt=state_getlist_ptr(tgtptr->index); - assert(ptgt!=NULL); - if (psrc->fsa!=ptgt->fsa && strcmp(sym->name,uENTRYFUNC)!=0) - error(83,sym->name); /* this function is part of another machine */ - if (checkconflict(psrc,ptgt)) - error(84,sym->name); /* state conflict */ - } /* for (tgtptr) */ - } /* for (srcptr) */ - } /* for (sym) */ -} - -/* check whether the two state lists (whose ids are passed in) share any - * states - */ -int state_conflict_id(int listid1,int listid2) -{ - statelist *psrc,*ptgt; - - psrc=state_getlist_ptr(listid1); - assert(psrc!=NULL); - ptgt=state_getlist_ptr(listid2); - assert(ptgt!=NULL); - return checkconflict(psrc,ptgt); -} diff --git a/sourcepawn/compiler/sctracker.cpp b/sourcepawn/compiler/sctracker.cpp deleted file mode 100644 index b575adcf..00000000 --- a/sourcepawn/compiler/sctracker.cpp +++ /dev/null @@ -1,614 +0,0 @@ -/* vim: set ts=8 sts=2 sw=2 tw=99 et: */ -#include -#include -#include -#include -#include "sc.h" -#include "sctracker.h" - -memuse_list_t *heapusage = NULL; -memuse_list_t *stackusage = NULL; -funcenum_t *firstenum = NULL; -funcenum_t *lastenum = NULL; -pstruct_t *firststruct = NULL; -pstruct_t *laststruct = NULL; -methodmap_t *methodmap_first = NULL; -methodmap_t *methodmap_last = NULL; - -structarg_t *pstructs_getarg(pstruct_t *pstruct, const char *member) -{ - int i; - - for (i=0; iargcount; i++) { - if (strcmp(pstruct->args[i]->name, member) == 0) - return pstruct->args[i]; - } - - return NULL; -} - -pstruct_t *pstructs_add(const char *name) -{ - pstruct_t *p = (pstruct_t *)malloc(sizeof(pstruct_t)); - - memset(p, 0, sizeof(pstruct_t)); - strcpy(p->name, name); - - if (!firststruct) { - firststruct = p; - laststruct = p; - } else { - laststruct->next = p; - laststruct = p; - } - - return p; -} - -void pstructs_free() -{ - pstruct_t *p, *next; - - p = firststruct; - while (p) { - while (p->argcount--) - free(p->args[p->argcount]); - free(p->args); - next = p->next; - free(p); - p = next; - } - firststruct = NULL; - laststruct = NULL; -} - -pstruct_t *pstructs_find(const char *name) -{ - pstruct_t *p = firststruct; - - while (p) { - if (strcmp(p->name, name) == 0) - return p; - p = p->next; - } - - return NULL; -} - -structarg_t *pstructs_addarg(pstruct_t *pstruct, const structarg_t *arg) -{ - structarg_t *newarg; - int i; - - for (i=0; iargcount; i++) { - if (strcmp(pstruct->args[i]->name, arg->name) == 0) { - /* Don't allow dup names */ - return NULL; - } - } - - newarg = (structarg_t *)malloc(sizeof(structarg_t)); - - memcpy(newarg, arg, sizeof(structarg_t)); - - if (pstruct->argcount == 0) { - pstruct->args = (structarg_t **)malloc(sizeof(structarg_t *) * 1); - } else { - pstruct->args = (structarg_t **)realloc( - pstruct->args, - sizeof(structarg_t *) * (pstruct->argcount + 1)); - } - - newarg->offs = pstruct->argcount * sizeof(cell); - newarg->index = pstruct->argcount; - pstruct->args[pstruct->argcount++] = newarg; - - return newarg; -} - -void funcenums_free() -{ - funcenum_t *e, *next; - - e = firstenum; - while (e) { - functag_t *tag, *nexttag; - tag = e->first; - while (tag) { - nexttag = tag->next; - free(tag); - tag = nexttag; - } - next = e->next; - free(e); - e = next; - } - - firstenum = NULL; - lastenum = NULL; -} - -funcenum_t *funcenums_find_by_tag(int tag) -{ - funcenum_t *e = firstenum; - - while (e) { - if (e->tag == tag) - return e; - e = e->next; - } - - return NULL; -} - -funcenum_t *funcenums_add(const char *name) -{ - funcenum_t *e = (funcenum_t *)malloc(sizeof(funcenum_t)); - - memset(e, 0, sizeof(funcenum_t)); - - if (!firstenum) { - firstenum = e; - lastenum = e; - } else { - lastenum->next = e; - lastenum = e; - } - - strcpy(e->name, name); - e->tag = pc_addtag_flags((char *)name, FIXEDTAG|FUNCTAG); - - return e; -} - -funcenum_t *funcenum_for_symbol(symbol *sym) -{ - functag_t ft; - memset(&ft, 0, sizeof(ft)); - - ft.ret_tag = sym->tag; - ft.usage = uPUBLIC & (sym->usage & uRETVALUE); - ft.argcount = 0; - ft.ommittable = FALSE; - for (arginfo *arg = sym->dim.arglist; arg->ident; arg++) { - funcarg_t *dest = &ft.args[ft.argcount++]; - - dest->tagcount = arg->numtags; - memcpy(dest->tags, arg->tags, arg->numtags * sizeof(int)); - - dest->dimcount = arg->numdim; - memcpy(dest->dims, arg->dim, arg->numdim * sizeof(int)); - - dest->ident = arg->ident; - dest->fconst = !!(arg->usage & uCONST); - dest->ommittable = FALSE; - } - - char name[METHOD_NAMEMAX+1]; - UTIL_Format(name, sizeof(name), "::ft:%s:%d:%d", sym->name, sym->addr, sym->codeaddr); - - funcenum_t *fe = funcenums_add(name); - functags_add(fe, &ft); - - return fe; -} - -// Finds a functag that was created intrinsically. -functag_t *functag_find_intrinsic(int tag) -{ - funcenum_t *fe = funcenums_find_by_tag(tag); - if (!fe) - return NULL; - - if (strncmp(fe->name, "::ft:", 5) != 0) - return NULL; - - assert(fe->first && fe->first == fe->last); - return fe->first; -} - -functag_t *functags_add(funcenum_t *en, functag_t *src) -{ - functag_t *t = (functag_t *)malloc(sizeof(functag_t)); - - memcpy(t, src, sizeof(functag_t)); - - t->next = NULL; - - if (en->first == NULL) { - en->first = t; - en->last = t; - } else { - en->last->next = t; - en->last = t; - } - - return t; -} - -/** - * Creates a new mem usage tracker entry - */ -void _push_memlist(memuse_list_t **head) -{ - memuse_list_t *newlist = (memuse_list_t *)malloc(sizeof(memuse_list_t)); - if (*head != NULL) - { - newlist->list_id = (*head)->list_id + 1; - } else { - newlist->list_id = 0; - } - newlist->prev = *head; - newlist->head = NULL; - *head = newlist; -} - -/** - * Pops a heap list but does not free it. - */ -memuse_list_t *_pop_save_memlist(memuse_list_t **head) -{ - memuse_list_t *oldlist = *head; - *head = (*head)->prev; - return oldlist; -} - -/** - * Marks a memory usage on a memory list - */ -int _mark_memlist(memuse_list_t *head, int type, int size) -{ - memuse_t *use; - if (type==MEMUSE_STATIC && size==0) - { - return 0; - } - use=head->head; - if (use && (type==MEMUSE_STATIC) - && (use->type == type)) - { - use->size += size; - } else { - use=(memuse_t *)malloc(sizeof(memuse_t)); - use->type=type; - use->size=size; - use->prev=head->head; - head->head=use; - } - return size; -} - -void _reset_memlist(memuse_list_t **head) -{ - memuse_list_t *curlist = *head; - memuse_list_t *tmplist; - while (curlist) { - memuse_t *curuse = curlist->head; - memuse_t *tmpuse; - while (curuse) { - tmpuse = curuse->prev; - free(curuse); - curuse = tmpuse; - } - tmplist = curlist->prev; - free(curlist); - curlist = tmplist; - } - *head = NULL; -} - - -/** - * Wrapper for pushing the heap list - */ -void pushheaplist() -{ - _push_memlist(&heapusage); -} - -/** - * Wrapper for popping and saving the heap list - */ -memuse_list_t *popsaveheaplist() -{ - return _pop_save_memlist(&heapusage); -} - -/** - * Wrapper for marking the heap - */ -int markheap(int type, int size) -{ - return _mark_memlist(heapusage, type, size); -} - -/** - * Wrapper for pushing the stack list - */ -void pushstacklist() -{ - _push_memlist(&stackusage); -} - -/** - * Wrapper for marking the stack - */ -int markstack(int type, int size) -{ - return _mark_memlist(stackusage, type, size); -} - -/** - * Generates code to free all heap allocations on a tracker - */ -void _heap_freeusage(memuse_list_t *heap, int dofree) -{ - memuse_t *cur=heap->head; - memuse_t *tmp; - while (cur) { - if (cur->type == MEMUSE_STATIC) { - modheap((-1)*cur->size*sizeof(cell)); - } else { - modheap_i(); - } - if (dofree) { - tmp=cur->prev; - free(cur); - cur=tmp; - } else { - cur=cur->prev; - } - } - if (dofree) - heap->head=NULL; -} - -void _stack_genusage(memuse_list_t *stack, int dofree) -{ - memuse_t *cur = stack->head; - memuse_t *tmp; - while (cur) - { - if (cur->type == MEMUSE_DYNAMIC) - { - /* no idea yet */ - assert(0); - } else { - modstk(cur->size * sizeof(cell)); - } - if (dofree) - { - tmp = cur->prev; - free(cur); - cur = tmp; - } else { - cur = cur->prev; - } - } - if (dofree) - { - stack->head = NULL; - } -} - -/** - * Pops a heap list and frees it. - */ -void popheaplist() -{ - memuse_list_t *oldlist; - assert(heapusage!=NULL); - - _heap_freeusage(heapusage, 1); - assert(heapusage->head==NULL); - - oldlist=heapusage->prev; - free(heapusage); - heapusage=oldlist; -} - -void genstackfree(int stop_id) -{ - memuse_list_t *curlist = stackusage; - while (curlist && curlist->list_id > stop_id) - { - _stack_genusage(curlist, 0); - curlist = curlist->prev; - } -} - -void genheapfree(int stop_id) -{ - memuse_list_t *curlist = heapusage; - while (curlist && curlist->list_id > stop_id) - { - _heap_freeusage(curlist, 0); - curlist = curlist->prev; - } -} - -void popstacklist(int codegen) -{ - memuse_list_t *oldlist; - assert(stackusage != NULL); - - if (codegen) - { - _stack_genusage(stackusage, 1); - assert(stackusage->head==NULL); - } else { - memuse_t *use = stackusage->head; - while (use) { - memuse_t *temp = use->prev; - free(use); - use = temp; - } - } - - oldlist = stackusage->prev; - free(stackusage); - stackusage = oldlist; -} - -void resetstacklist() -{ - _reset_memlist(&stackusage); -} - -void resetheaplist() -{ - _reset_memlist(&heapusage); -} - -void methodmap_add(methodmap_t *map) -{ - if (!methodmap_first) { - methodmap_first = map; - methodmap_last = map; - } else { - methodmap_last->next = map; - methodmap_last = map; - } -} - -methodmap_t *methodmap_find_by_tag(int tag) -{ - methodmap_t *ptr = methodmap_first; - for (; ptr; ptr = ptr->next) { - if (ptr->tag == tag) - return ptr; - } - return NULL; -} - -methodmap_t *methodmap_find_by_name(const char *name) -{ - int tag = pc_findtag(name); - if (tag == -1) - return NULL; - return methodmap_find_by_tag(tag); -} - -methodmap_method_t *methodmap_find_method(methodmap_t *map, const char *name) -{ - size_t i; - for (i = 0; i < map->nummethods; i++) { - if (strcmp(map->methods[i]->name, name) == 0) - return map->methods[i]; - } - if (map->parent) - return methodmap_find_method(map->parent, name); - return NULL; -} - -void methodmaps_free() -{ - methodmap_t *ptr = methodmap_first; - while (ptr) { - methodmap_t *next = ptr->next; - for (size_t i = 0; i < ptr->nummethods; i++) - free(ptr->methods[i]); - free(ptr->methods); - free(ptr); - ptr = next; - } - methodmap_first = NULL; - methodmap_last = NULL; -} - -LayoutSpec deduce_layout_spec_by_tag(int tag) -{ - symbol *sym; - const char *name; - methodmap_t *map; - if ((map = methodmap_find_by_tag(tag)) != NULL) - return map->spec; - if (tag & FUNCTAG) - return Layout_FuncTag; - - name = pc_tagname(tag); - if (pstructs_find(name)) - return Layout_PawnStruct; - if ((sym = findglb(name, sGLOBAL)) != NULL) - return Layout_Enum; - - return Layout_None; -} - -LayoutSpec deduce_layout_spec_by_name(const char *name) -{ - symbol *sym; - methodmap_t *map; - int tag = pc_findtag(name); - if (tag != -1 && (tag & FUNCTAG)) - return Layout_FuncTag; - if (pstructs_find(name)) - return Layout_PawnStruct; - if ((map = methodmap_find_by_name(name)) != NULL) - return map->spec; - if ((sym = findglb(name, sGLOBAL)) != NULL) - return Layout_Enum; - - return Layout_None; -} - -const char *layout_spec_name(LayoutSpec spec) -{ - switch (spec) { - case Layout_None: - return ""; - case Layout_Enum: - return "enum"; - case Layout_FuncTag: - return "functag"; - case Layout_PawnStruct: - return "deprecated-struct"; - case Layout_MethodMap: - return "methodmap"; - case Layout_Class: - return "class"; - } - return ""; -} - -int can_redef_layout_spec(LayoutSpec def1, LayoutSpec def2) -{ - // Normalize the ordering, since these checks are symmetrical. - if (def1 > def2) { - LayoutSpec temp = def2; - def2 = def1; - def1 = temp; - } - - switch (def1) { - case Layout_None: - return TRUE; - case Layout_Enum: - if (def2 == Layout_Enum || def2 == Layout_FuncTag) - return TRUE; - return def2 == Layout_MethodMap; - case Layout_FuncTag: - return def2 == Layout_Enum || def2 == Layout_FuncTag; - case Layout_PawnStruct: - case Layout_MethodMap: - return FALSE; - case Layout_Class: - return FALSE; - } - return FALSE; -} - -size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - size_t len = vsnprintf(buffer, maxlength, fmt, ap); - va_end(ap); - - if (len >= maxlength) { - buffer[maxlength - 1] = '\0'; - return maxlength - 1; - } - return len; -} diff --git a/sourcepawn/compiler/sctracker.h b/sourcepawn/compiler/sctracker.h deleted file mode 100644 index 27f44ecc..00000000 --- a/sourcepawn/compiler/sctracker.h +++ /dev/null @@ -1,189 +0,0 @@ -/* vim: set sts=2 ts=8 sw=2 tw=99 et: */ -#ifndef _INCLUDE_SOURCEPAWN_COMPILER_TRACKER_H_ -#define _INCLUDE_SOURCEPAWN_COMPILER_TRACKER_H_ - -#define MEMUSE_STATIC 0 -#define MEMUSE_DYNAMIC 1 - -typedef struct memuse_s { - int type; /* MEMUSE_STATIC or MEMUSE_DYNAMIC */ - int size; /* size of array for static (0 for dynamic) */ - struct memuse_s *prev; /* previous block on the list */ -} memuse_t; - -typedef struct memuse_list_s { - struct memuse_list_s *prev; /* last used list */ - int list_id; - memuse_t *head; /* head of the current list */ -} memuse_list_t; - -typedef struct funcarg_s -{ - int tagcount; - int tags[sTAGS_MAX]; - int dimcount; - int dims[sDIMEN_MAX]; - int ident; - int fconst; - int ommittable; -} funcarg_t; - -typedef struct functag_s -{ - int ret_tag; - int usage; - int argcount; - int ommittable; - funcarg_t args[sARGS_MAX]; - struct functag_s *next; -} functag_t; - -typedef struct funcenum_s -{ - int tag; - char name[METHOD_NAMEMAX+1]; - functag_t *first; - functag_t *last; - struct funcenum_s *next; -} funcenum_t; - -typedef struct structarg_s -{ - int tag; - int dimcount; - int dims[sDIMEN_MAX]; - char name[sNAMEMAX+1]; - int fconst; - int ident; - unsigned int offs; - int index; -} structarg_t; - -typedef struct pstruct_s -{ - int argcount; - char name[sNAMEMAX+1]; - structarg_t **args; - struct pstruct_s *next; -} pstruct_t; - -// The ordering of these definitions should be preserved for -// can_redef_layout_spec(). -typedef enum LayoutSpec_t -{ - Layout_None, - Layout_Enum, - Layout_FuncTag, - Layout_PawnStruct, - Layout_MethodMap, - Layout_Class -} LayoutSpec; - -typedef struct methodmap_method_s -{ - char name[METHOD_NAMEMAX + 1]; - symbol *target; - symbol *getter; - symbol *setter; - bool is_static; - - int property_tag() const { - assert(getter || setter); - if (getter) - return getter->tag; - arginfo *thisp = &setter->dim.arglist[0]; - if (thisp->ident == 0) - return pc_tag_void; - arginfo *valp = &setter->dim.arglist[1]; - if (valp->ident != iVARIABLE || valp->numtags != 1) - return pc_tag_void; - return valp->tags[0]; - } -} methodmap_method_t; - -struct methodmap_t -{ - methodmap_t *next; - methodmap_t *parent; - int tag; - int nullable; - LayoutSpec spec; - char name[sNAMEMAX+1]; - methodmap_method_t **methods; - size_t nummethods; - - // Shortcut. - methodmap_method_t *dtor; - methodmap_method_t *ctor; -}; - -/** - * Pawn Structs - */ -pstruct_t *pstructs_add(const char *name); -void pstructs_free(); -pstruct_t *pstructs_find(const char *name); -structarg_t *pstructs_addarg(pstruct_t *pstruct, const structarg_t *arg); -structarg_t *pstructs_getarg(pstruct_t *pstruct, const char *member); - -/** - * Function enumeration tags - */ -void funcenums_free(); -funcenum_t *funcenums_add(const char *name); -funcenum_t *funcenums_find_by_tag(int tag); -functag_t *functags_add(funcenum_t *en, functag_t *src); -funcenum_t *funcenum_for_symbol(symbol *sym); -functag_t *functag_find_intrinsic(int tag); - -/** - * Given a name or tag, find any extra weirdness it has associated with it. - */ -LayoutSpec deduce_layout_spec_by_tag(int tag); -LayoutSpec deduce_layout_spec_by_name(const char *name); -const char *layout_spec_name(LayoutSpec spec); -int can_redef_layout_spec(LayoutSpec olddef, LayoutSpec newdef); - -/** - * Heap functions - */ -void pushheaplist(); -memuse_list_t *popsaveheaplist(); -void popheaplist(); -int markheap(int type, int size); - -/** - * Stack functions - */ -void pushstacklist(); -void popstacklist(int codegen); -int markstack(int type, int size); -/** - * Generates code to free mem usage, but does not pop the list. - * This is used for code like dobreak()/docont()/doreturn(). - * stop_id is the list at which to stop generating. - */ -void genstackfree(int stop_id); -void genheapfree(int stop_id); - -/** - * Resets a mem list by freeing everything - */ -void resetstacklist(); -void resetheaplist(); - -/** - * Method maps. - */ -void methodmap_add(methodmap_t *map); -methodmap_t *methodmap_find_by_tag(int tag); -methodmap_t *methodmap_find_by_name(const char *name); -methodmap_method_t *methodmap_find_method(methodmap_t *map, const char *name); -void methodmaps_free(); - -extern memuse_list_t *heapusage; -extern memuse_list_t *stackusage; - -size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...); - -#endif //_INCLUDE_SOURCEPAWN_COMPILER_TRACKER_H_ diff --git a/sourcepawn/compiler/scvars.cpp b/sourcepawn/compiler/scvars.cpp deleted file mode 100644 index 3f1a5131..00000000 --- a/sourcepawn/compiler/scvars.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* Pawn compiler - * - * Global (cross-module) variables. - * - * Copyright (c) ITB CompuPhase, 1997-2006 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ - */ -#include -#include /* for _MAX_PATH */ -#include "sc.h" -#include "sp_symhash.h" - -/* global variables - * - * All global variables that are shared amongst the compiler files are - * declared here. - */ -symbol loctab; /* local symbol table */ -symbol glbtab; /* global symbol table */ -cell *litq; /* the literal queue */ -unsigned char pline[sLINEMAX+1]; /* the line read from the input file */ -const unsigned char *lptr; /* points to the current position in "pline" */ -constvalue tagname_tab = { NULL, "", 0, 0}; /* tagname table */ -constvalue libname_tab = { NULL, "", 0, 0}; /* library table (#pragma library "..." syntax) */ -constvalue *curlibrary = NULL; /* current library */ -int pc_addlibtable = TRUE; /* is the library table added to the AMX file? */ -symbol *curfunc; /* pointer to current function */ -char *inpfname; /* pointer to name of the file currently read from */ -char outfname[_MAX_PATH]; /* intermediate (assembler) file name */ -char binfname[_MAX_PATH]; /* binary file name */ -char errfname[_MAX_PATH]; /* error file name */ -char sc_ctrlchar = CTRL_CHAR; /* the control character (or escape character)*/ -char sc_ctrlchar_org = CTRL_CHAR;/* the default control character */ -int litidx = 0; /* index to literal table */ -int litmax = sDEF_LITMAX; /* current size of the literal table */ -int stgidx = 0; /* index to the staging buffer */ -int sc_labnum = 0; /* number of (internal) labels */ -int staging = 0; /* true if staging output */ -cell declared = 0; /* number of local cells declared */ -cell glb_declared=0; /* number of global cells declared */ -cell code_idx = 0; /* number of bytes with generated code */ -int ntv_funcid= 0; /* incremental number of native function */ -int errnum = 0; /* number of errors */ -int warnnum = 0; /* number of warnings */ -int sc_debug = sCHKBOUNDS; /* by default: bounds checking+assertions */ -int sc_packstr= FALSE; /* strings are packed by default? */ -int sc_asmfile= FALSE; /* create .ASM file? */ -int sc_listing= FALSE; /* create .LST file? */ -int sc_compress=TRUE; /* compress bytecode? */ -int sc_needsemicolon=TRUE;/* semicolon required to terminate expressions? */ -int sc_dataalign=sizeof(cell);/* data alignment value */ -int sc_alignnext=FALSE; /* must frame of the next function be aligned? */ -int pc_docexpr=FALSE; /* must expression be attached to documentation comment? */ -int curseg = 0; /* 1 if currently parsing CODE, 2 if parsing DATA */ -cell pc_stksize=sDEF_AMXSTACK;/* default stack size */ -cell pc_amxlimit=0; /* default abstract machine size limit = none */ -cell pc_amxram=0; /* default abstract machine data size limit = none */ -int freading = FALSE; /* Is there an input file ready for reading? */ -int fline = 0; /* the line number in the current file */ -short fnumber = 0; /* the file number in the file table (debugging) */ -short fcurrent= 0; /* current file being processed (debugging) */ -short sc_intest=FALSE; /* true if inside a test */ -int sideeffect= 0; /* true if an expression causes a side-effect */ -int stmtindent= 0; /* current indent of the statement */ -int indent_nowarn=FALSE;/* skip warning "217 loose indentation" */ -int sc_tabsize=8; /* number of spaces that a TAB represents */ -short sc_allowtags=TRUE; /* allow/detect tagnames in lex() */ -int sc_status; /* read/write status */ -int sc_err_status; -int sc_rationaltag=0; /* tag for rational numbers */ -int rational_digits=0; /* number of fractional digits */ -int sc_allowproccall=0; /* allow/detect tagnames in lex() */ -short sc_is_utf8=FALSE; /* is this source file in UTF-8 encoding */ -char *pc_deprecate=NULL;/* if non-null, mark next declaration as deprecated */ -int sc_curstates=0; /* ID of the current state list */ -int pc_optimize=sOPTIMIZE_NOMACRO; /* (peephole) optimization level */ -int pc_memflags=0; /* special flags for the stack/heap usage */ -int sc_showincludes=0; /* show include files */ -int sc_require_newdecls=0; /* Require new-style declarations */ -bool sc_warnings_are_errors=false; - -constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */ -constvalue sc_state_tab = { NULL, "", 0, 0}; /* state table */ - -void *inpf = NULL; /* file read from (source or include) */ -void *inpf_org= NULL; /* main source file */ -void *outf = NULL; /* (intermediate) text file written to */ - -jmp_buf errbuf; - -HashTable *sp_Globals = NULL; - -#if !defined SC_LIGHT - int sc_makereport=FALSE; /* generate a cross-reference report */ -#endif - -#if defined __WATCOMC__ && !defined NDEBUG - /* Watcom's CVPACK dislikes .OBJ files without functions */ - static int dummyfunc(void) - { - return 0; - } -#endif diff --git a/sourcepawn/compiler/smx-builder.cpp b/sourcepawn/compiler/smx-builder.cpp deleted file mode 100644 index d33f0330..00000000 --- a/sourcepawn/compiler/smx-builder.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// vim: set sts=2 ts=8 sw=2 tw=99 et: -// -// Copyright (C) 2012-2014 David Anderson -// -// This file is part of SourcePawn. -// -// SourcePawn is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free -// Software Foundation, either version 3 of the License, or (at your option) -// any later version. -// -// SourcePawn 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 -// SourcePawn. If not, see http://www.gnu.org/licenses/. -#include "smx-builder.h" - -using namespace ke; -using namespace sp; - -SmxBuilder::SmxBuilder() -{ -} - -bool -SmxBuilder::write(ISmxBuffer *buf) -{ - sp_file_hdr_t header; - header.magic = SmxConsts::FILE_MAGIC; - header.version = SmxConsts::SP1_VERSION_1_1; - header.compression = SmxConsts::FILE_COMPRESSION_NONE; - - header.disksize = sizeof(header) + - sizeof(sp_file_section_t) * sections_.length(); - - // Note that |dataoffs| here is just to mimic what it would be in earlier - // versions of Pawn. Its value does not actually matter per the SMX spec, - // aside from having to be >= sizeof(sp_file_hdr_t). Here, we hint that - // only the region after the section list and names should be compressed. - header.dataoffs = header.disksize; - - size_t current_string_offset = 0; - for (size_t i = 0; i < sections_.length(); i++) { - Ref section = sections_[i]; - header.disksize += section->length(); - current_string_offset += section->name().length() + 1; - } - header.disksize += current_string_offset; - header.dataoffs += current_string_offset; - - header.imagesize = header.disksize; - header.sections = sections_.length(); - - // We put the string table after the sections table. - header.stringtab = sizeof(header) + sizeof(sp_file_section_t) * sections_.length(); - - if (!buf->write(&header, sizeof(header))) - return false; - - size_t current_offset = sizeof(header); - size_t current_data_offset = header.stringtab + current_string_offset; - current_string_offset = 0; - for (size_t i = 0; i < sections_.length(); i++) { - sp_file_section_t s; - s.nameoffs = current_string_offset; - s.dataoffs = current_data_offset; - s.size = sections_[i]->length(); - if (!buf->write(&s, sizeof(s))) - return false; - - current_offset += sizeof(s); - current_data_offset += s.size; - current_string_offset += sections_[i]->name().length() + 1; - } - assert(buf->pos() == current_offset); - assert(current_offset == header.stringtab); - - for (size_t i = 0; i < sections_.length(); i++) { - const AString &name = sections_[i]->name(); - if (!buf->write(name.chars(), name.length() + 1)) - return false; - } - current_offset += current_string_offset; - - assert(buf->pos() == current_offset); - - for (size_t i = 0; i < sections_.length(); i++) { - if (!sections_[i]->write(buf)) - return false; - current_offset += sections_[i]->length(); - } - - assert(buf->pos() == current_offset); - assert(current_offset == header.disksize); - - return true; -} - -bool -SmxNameTable::write(ISmxBuffer *buf) -{ - for (size_t i = 0; i < names_.length(); i++) { - Atom *str = names_[i]; - if (!buf->write(str->chars(), str->length() + 1)) - return false; - } - return true; -} - diff --git a/sourcepawn/compiler/smx-builder.h b/sourcepawn/compiler/smx-builder.h deleted file mode 100644 index 57b1eb6e..00000000 --- a/sourcepawn/compiler/smx-builder.h +++ /dev/null @@ -1,214 +0,0 @@ -// vim: set sts=2 ts=8 sw=2 tw=99 et: -// -// Copyright (C) 2012-2014 AlliedModders LLC, David Anderson -// -// This file is part of SourcePawn. -// -// SourcePawn is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free -// Software Foundation, either version 3 of the License, or (at your option) -// any later version. -// -// SourcePawn 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 -// SourcePawn. If not, see http://www.gnu.org/licenses/. -#ifndef _include_spcomp2_smx_builder_h_ -#define _include_spcomp2_smx_builder_h_ - -#include -#include -#include -#include -#include -#include "string-pool.h" -#include "memory-buffer.h" - -namespace ke { - -// An SmxSection is a named blob of data. -class SmxSection : public Refcounted -{ - public: - SmxSection(const char *name) - : name_(name) - { - } - - virtual bool write(ISmxBuffer *buf) = 0; - virtual size_t length() const = 0; - - const AString &name() const { - return name_; - } - - private: - AString name_; -}; - -// An SmxBlobSection is a section that has some kind of header structure -// (specified as a template parameter), and then an arbitrary run of bytes -// immediately after. -template -class SmxBlobSection : public SmxSection -{ - public: - SmxBlobSection(const char *name) - : SmxSection(name), - extra_(nullptr), - extra_len_(0) - { - memset(&t_, 0, sizeof(t_)); - } - - T &header() { - return t_; - } - void setBlob(uint8_t *blob, size_t len) { - extra_ = blob; - extra_len_ = len; - } - bool write(ISmxBuffer *buf) KE_OVERRIDE { - if (!buf->write(&t_, sizeof(t_))) - return false; - if (!extra_len_) - return true; - return buf->write(extra_, extra_len_); - } - size_t length() const KE_OVERRIDE { - return sizeof(t_) + extra_len_; - } - - private: - T t_; - uint8_t *extra_; - size_t extra_len_; -}; - -// An SmxBlobSection without headers. -template <> -class SmxBlobSection : public SmxSection -{ - public: - SmxBlobSection(const char *name) - : SmxSection(name) - { - } - - void add(void *bytes, size_t len) { - buffer_.write(bytes, len); - } - bool write(ISmxBuffer *buf) KE_OVERRIDE { - return buf->write(buffer_.bytes(), buffer_.size()); - } - size_t length() const KE_OVERRIDE { - return buffer_.size(); - } - - private: - MemoryBuffer buffer_; -}; - -// An SmxListSection is a section that is a simple table of uniformly-sized -// structures. It has no header of its own. -template -class SmxListSection : public SmxSection -{ - public: - SmxListSection(const char *name) - : SmxSection(name) - { - } - - void append(const T &t) { - list_.append(t); - } - T &add() { - list_.append(T()); - return list_.back(); - } - bool write(ISmxBuffer *buf) KE_OVERRIDE { - return buf->write(list_.buffer(), list_.length() * sizeof(T)); - } - size_t length() const KE_OVERRIDE { - return count() * sizeof(T); - } - size_t count() const { - return list_.length(); - } - - private: - Vector list_; -}; - -// A name table is a blob of zero-terminated strings. Strings are entered -// into the table as atoms, so duplicate stings are not emitted. -class SmxNameTable : public SmxSection -{ - public: - SmxNameTable(const char *name) - : SmxSection(name), - buffer_size_(0) - { - name_table_.init(64); - } - - uint32_t add(StringPool &pool, const char *str) { - return add(pool.add(str)); - } - - uint32_t add(Atom *str) { - NameTable::Insert i = name_table_.findForAdd(str); - if (i.found()) - return i->value; - - assert(IsUint32AddSafe(buffer_size_, str->length() + 1)); - - uint32_t index = buffer_size_; - name_table_.add(i, str, index); - names_.append(str); - buffer_size_ += str->length() + 1; - return index; - } - - bool write(ISmxBuffer *buf) KE_OVERRIDE; - size_t length() const KE_OVERRIDE { - return buffer_size_; - } - - private: - struct HashPolicy { - static uint32_t hash(Atom *str) { - return HashPointer(str); - } - static bool matches(Atom *a, Atom *b) { - return a == b; - } - }; - typedef HashMap NameTable; - - NameTable name_table_; - Vector names_; - uint32_t buffer_size_; -}; - -class SmxBuilder -{ - public: - SmxBuilder(); - - bool write(ISmxBuffer *buf); - - void add(const Ref §ion) { - sections_.append(section); - } - - private: - Vector> sections_; -}; - -} // namespace ke - -#endif // _include_spcomp2_smx_builder_h_ diff --git a/sourcepawn/compiler/sp_symhash.cpp b/sourcepawn/compiler/sp_symhash.cpp deleted file mode 100644 index 1b50b0ae..00000000 --- a/sourcepawn/compiler/sp_symhash.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -#include -#include -#include -#include "sc.h" -#include "sp_symhash.h" -#include - -struct NameAndScope -{ - const char *name; - int fnumber; - int *cmptag; - mutable symbol *matched; - mutable int count; - - NameAndScope(const char *name, int fnumber, int *cmptag) - : name(name), - fnumber(fnumber), - cmptag(cmptag), - matched(nullptr), - count(0) - { - } -}; - -struct SymbolHashPolicy -{ - typedef symbol *Payload; - - // Everything with the same name has the same hash, because the compiler - // wants to know two names that have the same tag for some reason. Even - // so, we can't be that accurate, since we might match the right symbol - // very early. - static uint32_t hash(const NameAndScope &key) { - return ke::HashCharSequence(key.name, strlen(key.name)); - } - static uint32_t hash(const symbol *s) { - return ke::HashCharSequence(s->name, strlen(s->name)); - } - - static bool matches(const NameAndScope &key, symbol *sym) { - if (sym->parent && sym->ident != iCONSTEXPR) - return false; - if (sym->fnumber >= 0 && sym->fnumber != key.fnumber) - return false; - if (strcmp(key.name, sym->name) != 0) - return false; - if (key.cmptag) { - key.count++; - key.matched = sym; - if (*key.cmptag != sym->tag) - return false; - } - return true; - } - static bool matches(const symbol *key, symbol *sym) { - return key == sym; - } -}; - -struct HashTable : public ke::HashTable -{ -}; - -uint32_t -NameHash(const char *str) -{ - return ke::HashCharSequence(str, strlen(str)); -} - -HashTable *NewHashTable() -{ - HashTable *ht = new HashTable(); - if (!ht->init()) { - delete ht; - return nullptr; - } - return ht; -} - -void -DestroyHashTable(HashTable *ht) -{ - delete ht; -} - -symbol * -FindTaggedInHashTable(HashTable *ht, const char *name, int fnumber, int *cmptag) -{ - NameAndScope nas(name, fnumber, cmptag); - HashTable::Result r = ht->find(nas); - if (!r.found()) { - if (nas.matched) { - *cmptag = nas.count; - return nas.matched; - } - return nullptr; - } - - *cmptag = 1; - return *r; -} - -symbol * -FindInHashTable(HashTable *ht, const char *name, int fnumber) -{ - NameAndScope nas(name, fnumber, nullptr); - HashTable::Result r = ht->find(nas); - if (!r.found()) - return nullptr; - return *r; -} - -void -AddToHashTable(HashTable *ht, symbol *sym) -{ - HashTable::Insert i = ht->findForAdd(sym); - assert(!i.found()); - ht->add(i, sym); -} - -void -RemoveFromHashTable(HashTable *ht, symbol *sym) -{ - HashTable::Result r = ht->find(sym); - assert(r.found()); - ht->remove(r); -} diff --git a/sourcepawn/compiler/sp_symhash.h b/sourcepawn/compiler/sp_symhash.h deleted file mode 100644 index 3617368f..00000000 --- a/sourcepawn/compiler/sp_symhash.h +++ /dev/null @@ -1,18 +0,0 @@ -/* vim: set ts=4 sw=4 tw=99 et: */ -#ifndef _INCLUDE_SPCOMP_SYMHASH_H_ -#define _INCLUDE_SPCOMP_SYMHASH_H_ - -uint32_t NameHash(const char *str); - -struct HashTable; - -HashTable *NewHashTable(); -void DestroyHashTable(HashTable *ht); -void AddToHashTable(HashTable *ht, symbol *sym); -void RemoveFromHashTable(HashTable *ht, symbol *sym); -symbol *FindInHashTable(HashTable *ht, const char *name, int fnumber); -symbol *FindTaggedInHashTable(HashTable *ht, const char *name, int fnumber, - int *cmptag); - -#endif /* _INCLUDE_SPCOMP_SYMHASH_H_ */ - diff --git a/sourcepawn/compiler/string-pool.h b/sourcepawn/compiler/string-pool.h deleted file mode 100644 index 63ef10e0..00000000 --- a/sourcepawn/compiler/string-pool.h +++ /dev/null @@ -1,146 +0,0 @@ -/* vim: set ts=2 sw=2 tw=99 et: - * - * Copyright (C) 2012-2014 AlliedModders LLC, David Anderson - * - * This file is part of SourcePawn. - * - * SourcePawn is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version. - * - * SourcePawn 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 - * SourcePawn. If not, see http://www.gnu.org/licenses/. - */ -#ifndef _include_jitcraft_string_pool_h_ -#define _include_jitcraft_string_pool_h_ - -// string-pool is a collection of helpers to atomize/internalize strings. The -// StringPool class provides Atom objects which can be used for efficiently -// handling string sets or dictionaries. - -#include -#include -#include - -namespace ke { - -// An Atom is a string that has a unique instance. That is, any Atom("a") is -// guaranteed to be pointer-equivalent to another Atom("a"), as long as they -// originated from the same StringPool. -class Atom -{ - friend class StringPool; - - private: - Atom(const char *str, size_t len) - : str_(str, len) - { - } - - public: - size_t length() const { - return str_.length(); - } - const char *chars() const { - return str_.chars(); - } - - private: - AString str_; -}; - -// Helper class to use as a key for hash table lookups. -class CharsAndLength -{ - public: - CharsAndLength() - : str_(nullptr), - length_(0) - { - } - - CharsAndLength(const char *str, size_t length) - : str_(str), - length_(length) - { - } - - const char *str() const { - return str_; - } - size_t length() const { - return length_; - } - - private: - const char *str_; - size_t length_; -}; - -// Atom dictionary. -class StringPool -{ - public: - StringPool() - : table_(SystemAllocatorPolicy()) - { - init(); - } - - ~StringPool() - { - if (!table_.elements()) - return; - for (Table::iterator i(&table_); !i.empty(); i.next()) - delete *i; - } - - bool init() { - return table_.init(256); - } - - Atom *add(const char *str, size_t length) { - CharsAndLength chars(str, length); - Table::Insert p = table_.findForAdd(chars); - if (!p.found() && !table_.add(p, new Atom(str, length))) - return nullptr; - return *p; - } - - Atom *add(const char *str) { - return add(str, strlen(str)); - } - - private: - struct Policy { - typedef Atom *Payload; - - static uint32_t hash(const char *key) { - return HashCharSequence(key, strlen(key)); - } - - static uint32_t hash(const CharsAndLength &key) { - return HashCharSequence(key.str(), key.length()); - } - - static bool matches(const CharsAndLength &key, const Payload &e) { - if (key.length() != e->length()) - return false; - return strcmp(key.str(), e->chars()) == 0; - } - }; - - typedef HashTable Table; - - private: - Table table_; -}; - -} // namespace ke - -#endif // _include_jitcraft_string_pool_h_ diff --git a/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-1.sp b/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-1.sp deleted file mode 100644 index d26a946e..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-1.sp +++ /dev/null @@ -1,11 +0,0 @@ -methodmap Y -{ -}; - -class X < Y -{ -}; - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-1.txt b/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-1.txt deleted file mode 100644 index 1d0676ce..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-1.txt +++ /dev/null @@ -1 +0,0 @@ -cannot mix methodmaps and classes with inheritance diff --git a/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-2.sp b/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-2.sp deleted file mode 100644 index fee89626..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-2.sp +++ /dev/null @@ -1,11 +0,0 @@ -class Y -{ -}; - -methodmap X < Y -{ -}; - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-2.txt b/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-2.txt deleted file mode 100644 index 1d0676ce..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-mix-methodmap-and-class-2.txt +++ /dev/null @@ -1 +0,0 @@ -cannot mix methodmaps and classes with inheritance diff --git a/sourcepawn/compiler/tests/disabled/fail-none-to-obj.sp b/sourcepawn/compiler/tests/disabled/fail-none-to-obj.sp deleted file mode 100644 index 21ab11b7..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-none-to-obj.sp +++ /dev/null @@ -1,13 +0,0 @@ -class X -{ -}; - -f(X:x) -{ - return 3 -} - -public main() -{ - return f(2); -} diff --git a/sourcepawn/compiler/tests/disabled/fail-none-to-obj.txt b/sourcepawn/compiler/tests/disabled/fail-none-to-obj.txt deleted file mode 100644 index 4523d543..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-none-to-obj.txt +++ /dev/null @@ -1 +0,0 @@ -cannot coerce non-object type int to object type X diff --git a/sourcepawn/compiler/tests/disabled/fail-obj-to-any.sp b/sourcepawn/compiler/tests/disabled/fail-obj-to-any.sp deleted file mode 100644 index 6545cb49..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-obj-to-any.sp +++ /dev/null @@ -1,14 +0,0 @@ -class X -{ -}; - -f(any:x) -{ - return 3 -} - -public main() -{ - new X:x; - return f(x); -} diff --git a/sourcepawn/compiler/tests/disabled/fail-obj-to-any.txt b/sourcepawn/compiler/tests/disabled/fail-obj-to-any.txt deleted file mode 100644 index 69c73982..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-obj-to-any.txt +++ /dev/null @@ -1 +0,0 @@ -cannot coerce object type X to non-object type any diff --git a/sourcepawn/compiler/tests/disabled/fail-obj-to-multitag.sp b/sourcepawn/compiler/tests/disabled/fail-obj-to-multitag.sp deleted file mode 100644 index 4e92090a..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-obj-to-multitag.sp +++ /dev/null @@ -1,14 +0,0 @@ -class X -{ -}; - -f({X,Float}:x) -{ - return 3 -} - -public main() -{ - new X:x; - return f(x); -} diff --git a/sourcepawn/compiler/tests/disabled/fail-obj-to-multitag.txt b/sourcepawn/compiler/tests/disabled/fail-obj-to-multitag.txt deleted file mode 100644 index 46c7f41f..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-obj-to-multitag.txt +++ /dev/null @@ -1 +0,0 @@ -cannot use an object in a multi-tag selector diff --git a/sourcepawn/compiler/tests/disabled/fail-obj-to-none.sp b/sourcepawn/compiler/tests/disabled/fail-obj-to-none.sp deleted file mode 100644 index 85045712..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-obj-to-none.sp +++ /dev/null @@ -1,14 +0,0 @@ -class X -{ -}; - -f(x) -{ - return 3 -} - -public main() -{ - new X:x; - return f(x); -} diff --git a/sourcepawn/compiler/tests/disabled/fail-obj-to-none.txt b/sourcepawn/compiler/tests/disabled/fail-obj-to-none.txt deleted file mode 100644 index 20ceed6f..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-obj-to-none.txt +++ /dev/null @@ -1 +0,0 @@ -cannot coerce object type X to non-object type int diff --git a/sourcepawn/compiler/tests/disabled/fail-obj-to-varargs.sp b/sourcepawn/compiler/tests/disabled/fail-obj-to-varargs.sp deleted file mode 100644 index ba0d8014..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-obj-to-varargs.sp +++ /dev/null @@ -1,14 +0,0 @@ -class X -{ -}; - -f(...) -{ - return 3 -} - -public main() -{ - new X:x; - return f(x); -} diff --git a/sourcepawn/compiler/tests/disabled/fail-obj-to-varargs.txt b/sourcepawn/compiler/tests/disabled/fail-obj-to-varargs.txt deleted file mode 100644 index 20ceed6f..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-obj-to-varargs.txt +++ /dev/null @@ -1 +0,0 @@ -cannot coerce object type X to non-object type int diff --git a/sourcepawn/compiler/tests/disabled/fail-object-keyword-as-name.sp b/sourcepawn/compiler/tests/disabled/fail-object-keyword-as-name.sp deleted file mode 100644 index 756c2a69..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-object-keyword-as-name.sp +++ /dev/null @@ -1,5 +0,0 @@ -public Action:SomeEvent( Handle:event, const String:name[], bool:dontBroadcast) -{ - // error 143: new-style declarations should not have "new" - new object = GetEventInt(event, "object"); -} diff --git a/sourcepawn/compiler/tests/disabled/fail-object-keyword-as-name.txt b/sourcepawn/compiler/tests/disabled/fail-object-keyword-as-name.txt deleted file mode 100644 index ed270926..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-object-keyword-as-name.txt +++ /dev/null @@ -1 +0,0 @@ -(4) : error 157: 'object' is a reserved keyword diff --git a/sourcepawn/compiler/tests/disabled/fail-relabel-int-to-obj.sp b/sourcepawn/compiler/tests/disabled/fail-relabel-int-to-obj.sp deleted file mode 100644 index 0b238bdc..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-relabel-int-to-obj.sp +++ /dev/null @@ -1,14 +0,0 @@ -class X -{ -}; - -f(X:x) -{ - return 3 -} - -public main() -{ - new x; - return f(X:x); -} diff --git a/sourcepawn/compiler/tests/disabled/fail-relabel-int-to-obj.txt b/sourcepawn/compiler/tests/disabled/fail-relabel-int-to-obj.txt deleted file mode 100644 index 4523d543..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-relabel-int-to-obj.txt +++ /dev/null @@ -1 +0,0 @@ -cannot coerce non-object type int to object type X diff --git a/sourcepawn/compiler/tests/disabled/fail-relabel-obj-to-int.sp b/sourcepawn/compiler/tests/disabled/fail-relabel-obj-to-int.sp deleted file mode 100644 index 832774c3..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-relabel-obj-to-int.sp +++ /dev/null @@ -1,14 +0,0 @@ -class X -{ -}; - -f(x) -{ - return 3 -} - -public main() -{ - new X:x; - return f(_:x); -} diff --git a/sourcepawn/compiler/tests/disabled/fail-relabel-obj-to-int.txt b/sourcepawn/compiler/tests/disabled/fail-relabel-obj-to-int.txt deleted file mode 100644 index 20ceed6f..00000000 --- a/sourcepawn/compiler/tests/disabled/fail-relabel-obj-to-int.txt +++ /dev/null @@ -1 +0,0 @@ -cannot coerce object type X to non-object type int diff --git a/sourcepawn/compiler/tests/fail-array-on-implicit-this.sp b/sourcepawn/compiler/tests/fail-array-on-implicit-this.sp deleted file mode 100644 index 820c4524..00000000 --- a/sourcepawn/compiler/tests/fail-array-on-implicit-this.sp +++ /dev/null @@ -1,9 +0,0 @@ -native CloseHandle(Handle:handle[]); - -methodmap Handle { - public Close() = CloseHandle; -}; - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/fail-array-on-implicit-this.txt b/sourcepawn/compiler/tests/fail-array-on-implicit-this.txt deleted file mode 100644 index aedab634..00000000 --- a/sourcepawn/compiler/tests/fail-array-on-implicit-this.txt +++ /dev/null @@ -1 +0,0 @@ -method must have a first argument compatible with the methodmap type (Handle) diff --git a/sourcepawn/compiler/tests/fail-assign-null-to-any.sp b/sourcepawn/compiler/tests/fail-assign-null-to-any.sp deleted file mode 100644 index 16be5876..00000000 --- a/sourcepawn/compiler/tests/fail-assign-null-to-any.sp +++ /dev/null @@ -1,4 +0,0 @@ -Foo(any foo) {} -public Bar() { - Foo(null); -} diff --git a/sourcepawn/compiler/tests/fail-assign-null-to-any.txt b/sourcepawn/compiler/tests/fail-assign-null-to-any.txt deleted file mode 100644 index cb98bb52..00000000 --- a/sourcepawn/compiler/tests/fail-assign-null-to-any.txt +++ /dev/null @@ -1 +0,0 @@ -(3) : error 148: cannot assign null to a non-nullable type diff --git a/sourcepawn/compiler/tests/fail-assign-string-and-nonstring.sp b/sourcepawn/compiler/tests/fail-assign-string-and-nonstring.sp deleted file mode 100644 index d7f34615..00000000 --- a/sourcepawn/compiler/tests/fail-assign-string-and-nonstring.sp +++ /dev/null @@ -1,7 +0,0 @@ -public main() -{ - char x[40]; - any y[10]; - x = y; - y = x; -} diff --git a/sourcepawn/compiler/tests/fail-assign-string-and-nonstring.txt b/sourcepawn/compiler/tests/fail-assign-string-and-nonstring.txt deleted file mode 100644 index 102dad96..00000000 --- a/sourcepawn/compiler/tests/fail-assign-string-and-nonstring.txt +++ /dev/null @@ -1,2 +0,0 @@ -(5) : error 179: cannot assign char[] to any[], storage classes differ -(6) : error 179: cannot assign any[] to char[], storage classes differ diff --git a/sourcepawn/compiler/tests/fail-assign-to-this.sp b/sourcepawn/compiler/tests/fail-assign-to-this.sp deleted file mode 100644 index 2bd47b80..00000000 --- a/sourcepawn/compiler/tests/fail-assign-to-this.sp +++ /dev/null @@ -1,12 +0,0 @@ -methodmap Egg -{ - public void illegal(Egg x) { - this = x; - } -}; - -public main() -{ - Egg egg; - egg.illegal(egg); -} diff --git a/sourcepawn/compiler/tests/fail-assign-to-this.txt b/sourcepawn/compiler/tests/fail-assign-to-this.txt deleted file mode 100644 index 530c5065..00000000 --- a/sourcepawn/compiler/tests/fail-assign-to-this.txt +++ /dev/null @@ -1 +0,0 @@ -(4) : error 022: must be lvalue (non-constant) diff --git a/sourcepawn/compiler/tests/fail-bad-arg-decls.sp b/sourcepawn/compiler/tests/fail-bad-arg-decls.sp deleted file mode 100644 index cda0ec89..00000000 --- a/sourcepawn/compiler/tests/fail-bad-arg-decls.sp +++ /dev/null @@ -1,15 +0,0 @@ -stock A(int) -{ -} - -stock B(int[5] N) -{ -} - -stock C(int:N) -{ -} - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/fail-bad-arg-decls.txt b/sourcepawn/compiler/tests/fail-bad-arg-decls.txt deleted file mode 100644 index f6404967..00000000 --- a/sourcepawn/compiler/tests/fail-bad-arg-decls.txt +++ /dev/null @@ -1,3 +0,0 @@ -(1) : error 001: expected token: "-identifier-", but found ")" -(5) : error 140: new-style array types cannot specify dimension sizes as part of their type -(9) : warning 238: 'int:' is an illegal cast; use view_as(expression) diff --git a/sourcepawn/compiler/tests/fail-bad-array-decls.sp b/sourcepawn/compiler/tests/fail-bad-array-decls.sp deleted file mode 100644 index 0a834b8f..00000000 --- a/sourcepawn/compiler/tests/fail-bad-array-decls.sp +++ /dev/null @@ -1,17 +0,0 @@ -int[] gInvalid = {1}; - -public OnPluginStart() -{ - int v = 10; - int invalid1[v]; - int[] invalid2 = {1}; - static int[] invalid3 = {1}; -} - -void invalid_arg1(int invalid[]) -{ -} - -void invalid_arg2(int[] invalid = {1, 2, 3}) -{ -} diff --git a/sourcepawn/compiler/tests/fail-bad-array-decls.txt b/sourcepawn/compiler/tests/fail-bad-array-decls.txt deleted file mode 100644 index f415a354..00000000 --- a/sourcepawn/compiler/tests/fail-bad-array-decls.txt +++ /dev/null @@ -1,7 +0,0 @@ -(1) : error 162: cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name? -(6) : error 161: brackets after variable name indicate a fixed-size array, but a dynamic size was given - did you mean to use 'new int[size]' syntax? -(7) : error 160: brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given -(8) : error 165: cannot create dynamic arrays in static scope - did you mean to create a fixed-length array with brackets after the variable name? -(11) : error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x') -(15) : error 160: brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given - diff --git a/sourcepawn/compiler/tests/fail-bad-void.sp b/sourcepawn/compiler/tests/fail-bad-void.sp deleted file mode 100644 index 4e83660f..00000000 --- a/sourcepawn/compiler/tests/fail-bad-void.sp +++ /dev/null @@ -1,13 +0,0 @@ -void[] Bad1() -{ -} - -void Bad2; - -stock Bad3(void x) -{ -} - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/fail-bad-void.txt b/sourcepawn/compiler/tests/fail-bad-void.txt deleted file mode 100644 index 7d5d07c8..00000000 --- a/sourcepawn/compiler/tests/fail-bad-void.txt +++ /dev/null @@ -1,3 +0,0 @@ -(1) : error 145: invalid type expression -(5) : error 144: void cannot be used as a variable type -(7) : error 144: void cannot be used as a variable type diff --git a/sourcepawn/compiler/tests/fail-call-non-static-on-type.sp b/sourcepawn/compiler/tests/fail-call-non-static-on-type.sp deleted file mode 100644 index ac6df284..00000000 --- a/sourcepawn/compiler/tests/fail-call-non-static-on-type.sp +++ /dev/null @@ -1,12 +0,0 @@ -native printnum(t); - -methodmap X -{ - public int GetThing() { - return 10; - } -} - -public main() { - printnum(X.GetThing()); -} diff --git a/sourcepawn/compiler/tests/fail-call-non-static-on-type.txt b/sourcepawn/compiler/tests/fail-call-non-static-on-type.txt deleted file mode 100644 index 42c312db..00000000 --- a/sourcepawn/compiler/tests/fail-call-non-static-on-type.txt +++ /dev/null @@ -1 +0,0 @@ -(11) : error 176: non-static method or property 'GetThing' must be called with a value of type 'X' diff --git a/sourcepawn/compiler/tests/fail-call-static-via-instance.sp b/sourcepawn/compiler/tests/fail-call-static-via-instance.sp deleted file mode 100644 index 24a16591..00000000 --- a/sourcepawn/compiler/tests/fail-call-static-via-instance.sp +++ /dev/null @@ -1,13 +0,0 @@ -native printnum(t); - -methodmap X -{ - public static int GetThing() { - return 10; - } -} - -public main() { - X x; - printnum(x.GetThing()); -} diff --git a/sourcepawn/compiler/tests/fail-call-static-via-instance.txt b/sourcepawn/compiler/tests/fail-call-static-via-instance.txt deleted file mode 100644 index 9a7dbc95..00000000 --- a/sourcepawn/compiler/tests/fail-call-static-via-instance.txt +++ /dev/null @@ -1 +0,0 @@ -(12) : error 177: static method 'GetThing' must be invoked via its type (try 'X.GetThing') diff --git a/sourcepawn/compiler/tests/fail-cannot-view-as-void.sp b/sourcepawn/compiler/tests/fail-cannot-view-as-void.sp deleted file mode 100644 index bec4adf4..00000000 --- a/sourcepawn/compiler/tests/fail-cannot-view-as-void.sp +++ /dev/null @@ -1,3 +0,0 @@ -public float egg() { - return view_as(10); -} diff --git a/sourcepawn/compiler/tests/fail-cannot-view-as-void.txt b/sourcepawn/compiler/tests/fail-cannot-view-as-void.txt deleted file mode 100644 index c4631319..00000000 --- a/sourcepawn/compiler/tests/fail-cannot-view-as-void.txt +++ /dev/null @@ -1 +0,0 @@ -(2) : error 144: void cannot be used as a variable type diff --git a/sourcepawn/compiler/tests/fail-coerce-ref-string-to-any.sp b/sourcepawn/compiler/tests/fail-coerce-ref-string-to-any.sp deleted file mode 100644 index fc48d671..00000000 --- a/sourcepawn/compiler/tests/fail-coerce-ref-string-to-any.sp +++ /dev/null @@ -1,9 +0,0 @@ -f(any[] x) -{ -} - -public main() -{ - char x[10]; - f(x[1]); -} diff --git a/sourcepawn/compiler/tests/fail-coerce-ref-string-to-any.txt b/sourcepawn/compiler/tests/fail-coerce-ref-string-to-any.txt deleted file mode 100644 index 4d668d2b..00000000 --- a/sourcepawn/compiler/tests/fail-coerce-ref-string-to-any.txt +++ /dev/null @@ -1 +0,0 @@ -(8) : error 178: cannot coerce char[] to any[]; storage classes differ diff --git a/sourcepawn/compiler/tests/fail-coerce-string-to-any.sp b/sourcepawn/compiler/tests/fail-coerce-string-to-any.sp deleted file mode 100644 index 296f47cb..00000000 --- a/sourcepawn/compiler/tests/fail-coerce-string-to-any.sp +++ /dev/null @@ -1,9 +0,0 @@ -f(any[] x) -{ -} - -public main() -{ - char x[10]; - f(x); -} diff --git a/sourcepawn/compiler/tests/fail-coerce-string-to-any.txt b/sourcepawn/compiler/tests/fail-coerce-string-to-any.txt deleted file mode 100644 index 4d668d2b..00000000 --- a/sourcepawn/compiler/tests/fail-coerce-string-to-any.txt +++ /dev/null @@ -1 +0,0 @@ -(8) : error 178: cannot coerce char[] to any[]; storage classes differ diff --git a/sourcepawn/compiler/tests/fail-ctor-bad-return-type.sp b/sourcepawn/compiler/tests/fail-ctor-bad-return-type.sp deleted file mode 100644 index ee9ad489..00000000 --- a/sourcepawn/compiler/tests/fail-ctor-bad-return-type.sp +++ /dev/null @@ -1,13 +0,0 @@ -native Float:CreateHandle(count); -native CloseHandle(Handle:handle); - -methodmap Handle { - public Handle() = CreateHandle; - public Close() = CloseHandle; -}; - -public main() { - new Handle:handle = Handle(3); - handle.Close(); -} - diff --git a/sourcepawn/compiler/tests/fail-ctor-bad-return-type.txt b/sourcepawn/compiler/tests/fail-ctor-bad-return-type.txt deleted file mode 100644 index 59bc1840..00000000 --- a/sourcepawn/compiler/tests/fail-ctor-bad-return-type.txt +++ /dev/null @@ -1 +0,0 @@ -constructor function must return tag Handle diff --git a/sourcepawn/compiler/tests/fail-default-args-in-public.sp b/sourcepawn/compiler/tests/fail-default-args-in-public.sp deleted file mode 100644 index 97a39802..00000000 --- a/sourcepawn/compiler/tests/fail-default-args-in-public.sp +++ /dev/null @@ -1 +0,0 @@ -public x(param = 1) {} diff --git a/sourcepawn/compiler/tests/fail-default-args-in-public.txt b/sourcepawn/compiler/tests/fail-default-args-in-public.txt deleted file mode 100644 index 01947b24..00000000 --- a/sourcepawn/compiler/tests/fail-default-args-in-public.txt +++ /dev/null @@ -1 +0,0 @@ -(1) : error 059: function argument may not have a default value (variable "param") diff --git a/sourcepawn/compiler/tests/fail-delete-no-dtor.sp b/sourcepawn/compiler/tests/fail-delete-no-dtor.sp deleted file mode 100644 index 73b405b7..00000000 --- a/sourcepawn/compiler/tests/fail-delete-no-dtor.sp +++ /dev/null @@ -1,10 +0,0 @@ -native Handle:CreateHandle(); - -methodmap Handle { - public Handle() = CreateHandle; -}; - -public main() { - new Handle:handle = Handle(); - delete handle; -} diff --git a/sourcepawn/compiler/tests/fail-delete-no-dtor.txt b/sourcepawn/compiler/tests/fail-delete-no-dtor.txt deleted file mode 100644 index f8623d99..00000000 --- a/sourcepawn/compiler/tests/fail-delete-no-dtor.txt +++ /dev/null @@ -1 +0,0 @@ -cannot use delete, methodmap Handle has no destructor diff --git a/sourcepawn/compiler/tests/fail-dtor-extra-args.sp b/sourcepawn/compiler/tests/fail-dtor-extra-args.sp deleted file mode 100644 index d6bf6d5b..00000000 --- a/sourcepawn/compiler/tests/fail-dtor-extra-args.sp +++ /dev/null @@ -1,8 +0,0 @@ -native Q(X:handle, a); - -methodmap X { - public ~X() = Q; -} - -public main() { -} diff --git a/sourcepawn/compiler/tests/fail-dtor-extra-args.txt b/sourcepawn/compiler/tests/fail-dtor-extra-args.txt deleted file mode 100644 index 2f86263c..00000000 --- a/sourcepawn/compiler/tests/fail-dtor-extra-args.txt +++ /dev/null @@ -1 +0,0 @@ -destructors cannot have extra arguments diff --git a/sourcepawn/compiler/tests/fail-dtor-non-native.sp b/sourcepawn/compiler/tests/fail-dtor-non-native.sp deleted file mode 100644 index 6addca89..00000000 --- a/sourcepawn/compiler/tests/fail-dtor-non-native.sp +++ /dev/null @@ -1,10 +0,0 @@ -Q(X:handle) -{ -} - -methodmap X { - public ~X() = Q; -} - -public main() { -} diff --git a/sourcepawn/compiler/tests/fail-dtor-non-native.txt b/sourcepawn/compiler/tests/fail-dtor-non-native.txt deleted file mode 100644 index 43b690c2..00000000 --- a/sourcepawn/compiler/tests/fail-dtor-non-native.txt +++ /dev/null @@ -1 +0,0 @@ -destructors must be native functions diff --git a/sourcepawn/compiler/tests/fail-dtor-returns-value.sp b/sourcepawn/compiler/tests/fail-dtor-returns-value.sp deleted file mode 100644 index 26632f9c..00000000 --- a/sourcepawn/compiler/tests/fail-dtor-returns-value.sp +++ /dev/null @@ -1,8 +0,0 @@ -native bool:Q(); - -methodmap X { - public ~X() = Q; -} - -public main() { -} diff --git a/sourcepawn/compiler/tests/fail-dtor-returns-value.txt b/sourcepawn/compiler/tests/fail-dtor-returns-value.txt deleted file mode 100644 index 3825f3f5..00000000 --- a/sourcepawn/compiler/tests/fail-dtor-returns-value.txt +++ /dev/null @@ -1 +0,0 @@ -destructor should not have an explicit return type diff --git a/sourcepawn/compiler/tests/fail-duplicate-getter.sp b/sourcepawn/compiler/tests/fail-duplicate-getter.sp deleted file mode 100644 index 0cdfd6a0..00000000 --- a/sourcepawn/compiler/tests/fail-duplicate-getter.sp +++ /dev/null @@ -1,9 +0,0 @@ -methodmap Crab { - property int Crab { - public native get(); - public native get(); - } -} - -public main() { -} diff --git a/sourcepawn/compiler/tests/fail-duplicate-getter.txt b/sourcepawn/compiler/tests/fail-duplicate-getter.txt deleted file mode 100644 index c2b4feee..00000000 --- a/sourcepawn/compiler/tests/fail-duplicate-getter.txt +++ /dev/null @@ -1 +0,0 @@ -getter for Crab already exists diff --git a/sourcepawn/compiler/tests/fail-duplicate-methods.sp b/sourcepawn/compiler/tests/fail-duplicate-methods.sp deleted file mode 100644 index 071d9d7a..00000000 --- a/sourcepawn/compiler/tests/fail-duplicate-methods.sp +++ /dev/null @@ -1,8 +0,0 @@ -native X:Crab(X:x); -methodmap X { - public X2() = Crab; - public X2() = Crab; -} - -public main() { -} diff --git a/sourcepawn/compiler/tests/fail-duplicate-methods.txt b/sourcepawn/compiler/tests/fail-duplicate-methods.txt deleted file mode 100644 index f56c4be2..00000000 --- a/sourcepawn/compiler/tests/fail-duplicate-methods.txt +++ /dev/null @@ -1 +0,0 @@ -X2 was already defined on this methodmap diff --git a/sourcepawn/compiler/tests/fail-duplicate-property.sp b/sourcepawn/compiler/tests/fail-duplicate-property.sp deleted file mode 100644 index 25a42aaa..00000000 --- a/sourcepawn/compiler/tests/fail-duplicate-property.sp +++ /dev/null @@ -1,7 +0,0 @@ -methodmap Crab { - property int Crab; - property int Crab; -} - -public main() { -} diff --git a/sourcepawn/compiler/tests/fail-duplicate-property.txt b/sourcepawn/compiler/tests/fail-duplicate-property.txt deleted file mode 100644 index 8e4bf6a9..00000000 --- a/sourcepawn/compiler/tests/fail-duplicate-property.txt +++ /dev/null @@ -1 +0,0 @@ -Crab was already defined on this methodmap diff --git a/sourcepawn/compiler/tests/fail-dynamic-array-bad-type.sp b/sourcepawn/compiler/tests/fail-dynamic-array-bad-type.sp deleted file mode 100644 index 14a53f54..00000000 --- a/sourcepawn/compiler/tests/fail-dynamic-array-bad-type.sp +++ /dev/null @@ -1,4 +0,0 @@ -public main() -{ - int[] x = new float[3]; -} diff --git a/sourcepawn/compiler/tests/fail-dynamic-array-bad-type.txt b/sourcepawn/compiler/tests/fail-dynamic-array-bad-type.txt deleted file mode 100644 index d2e8545a..00000000 --- a/sourcepawn/compiler/tests/fail-dynamic-array-bad-type.txt +++ /dev/null @@ -1 +0,0 @@ -(3) : error 164: allocated array type 'float' doesn't match original type 'int' diff --git a/sourcepawn/compiler/tests/fail-indeterminate-string-literal.sp b/sourcepawn/compiler/tests/fail-indeterminate-string-literal.sp deleted file mode 100644 index 27bb31ea..00000000 --- a/sourcepawn/compiler/tests/fail-indeterminate-string-literal.sp +++ /dev/null @@ -1,8 +0,0 @@ -native print(const char[] str); -native printnum(num); - -public main() -{ - char[] egg = "!\n"; - return sizeof(egg); -} diff --git a/sourcepawn/compiler/tests/fail-indeterminate-string-literal.txt b/sourcepawn/compiler/tests/fail-indeterminate-string-literal.txt deleted file mode 100644 index ac9a565b..00000000 --- a/sourcepawn/compiler/tests/fail-indeterminate-string-literal.txt +++ /dev/null @@ -1 +0,0 @@ -(7) : error 163: indeterminate array size in "sizeof" expression (symbol "egg") diff --git a/sourcepawn/compiler/tests/fail-method-name-too-long.sp b/sourcepawn/compiler/tests/fail-method-name-too-long.sp deleted file mode 100644 index 55e07fac..00000000 --- a/sourcepawn/compiler/tests/fail-method-name-too-long.sp +++ /dev/null @@ -1,7 +0,0 @@ -methodmap ThisNameIsReallyLongWowItsVeryLong { - public ThisNameIsReallyLongWowItsVeryLong() { - } -} - -public main() { -} diff --git a/sourcepawn/compiler/tests/fail-method-name-too-long.txt b/sourcepawn/compiler/tests/fail-method-name-too-long.txt deleted file mode 100644 index b6856a3e..00000000 --- a/sourcepawn/compiler/tests/fail-method-name-too-long.txt +++ /dev/null @@ -1 +0,0 @@ -fully-qualified name "ThisNameIsReallyLongWowItsVeryLong.ThisNameIsReallyLongWowItsVeryLong" is too long, would be truncated to "ThisNameIsReallyLongWowItsVeryLong.ThisNameIsReallyLongWowItsVe" diff --git a/sourcepawn/compiler/tests/fail-method-on-array.sp b/sourcepawn/compiler/tests/fail-method-on-array.sp deleted file mode 100644 index 212d1879..00000000 --- a/sourcepawn/compiler/tests/fail-method-on-array.sp +++ /dev/null @@ -1,12 +0,0 @@ -native CloseHandle(Handle:handle); - -methodmap Handle { - public Close() = CloseHandle; -}; - -public main() -{ - new Handle:x[2]; - - x.Close(); -} diff --git a/sourcepawn/compiler/tests/fail-method-on-array.txt b/sourcepawn/compiler/tests/fail-method-on-array.txt deleted file mode 100644 index e01ded18..00000000 --- a/sourcepawn/compiler/tests/fail-method-on-array.txt +++ /dev/null @@ -1 +0,0 @@ -cannot call methods on an array diff --git a/sourcepawn/compiler/tests/fail-method-on-function.sp b/sourcepawn/compiler/tests/fail-method-on-function.sp deleted file mode 100644 index 4dd50a98..00000000 --- a/sourcepawn/compiler/tests/fail-method-on-function.sp +++ /dev/null @@ -1,10 +0,0 @@ -native CloseHandle(Handle:handle); - -methodmap Handle { - public Close() = CloseHandle; -}; - -public main() -{ - main.Close(); -} diff --git a/sourcepawn/compiler/tests/fail-method-on-function.txt b/sourcepawn/compiler/tests/fail-method-on-function.txt deleted file mode 100644 index 47a85b6f..00000000 --- a/sourcepawn/compiler/tests/fail-method-on-function.txt +++ /dev/null @@ -1 +0,0 @@ -cannot call methods on a function diff --git a/sourcepawn/compiler/tests/fail-method-requires-brace.sp b/sourcepawn/compiler/tests/fail-method-requires-brace.sp deleted file mode 100644 index c5f05f8e..00000000 --- a/sourcepawn/compiler/tests/fail-method-requires-brace.sp +++ /dev/null @@ -1,8 +0,0 @@ -methodmap Crab { - public Crab() return Crab:5; -}; - -public main() { - new Crab:crab = Crab(); - return _:crab; -} diff --git a/sourcepawn/compiler/tests/fail-method-requires-brace.txt b/sourcepawn/compiler/tests/fail-method-requires-brace.txt deleted file mode 100644 index 986fc3b9..00000000 --- a/sourcepawn/compiler/tests/fail-method-requires-brace.txt +++ /dev/null @@ -1 +0,0 @@ -expected token: "{", but found "return" diff --git a/sourcepawn/compiler/tests/fail-methodmap-as-rvalue.sp b/sourcepawn/compiler/tests/fail-methodmap-as-rvalue.sp deleted file mode 100644 index 1218fca6..00000000 --- a/sourcepawn/compiler/tests/fail-methodmap-as-rvalue.sp +++ /dev/null @@ -1,17 +0,0 @@ -native printnum(x); - -enum X { -}; - -methodmap X { - public X(int y) { - printnum(y); - return view_as(0); - } -}; - -public main() -{ - X x = X(5); - return X; -} diff --git a/sourcepawn/compiler/tests/fail-methodmap-as-rvalue.txt b/sourcepawn/compiler/tests/fail-methodmap-as-rvalue.txt deleted file mode 100644 index 7dfa5277..00000000 --- a/sourcepawn/compiler/tests/fail-methodmap-as-rvalue.txt +++ /dev/null @@ -1 +0,0 @@ -(16) : error 174: symbol 'X' is a type and cannot be used as a value diff --git a/sourcepawn/compiler/tests/fail-methodmap-missing-method.sp b/sourcepawn/compiler/tests/fail-methodmap-missing-method.sp deleted file mode 100644 index 36ebdba5..00000000 --- a/sourcepawn/compiler/tests/fail-methodmap-missing-method.sp +++ /dev/null @@ -1,13 +0,0 @@ -methodmap Duck -{ - public void MyFunc() - { - // this will compile fine until this function is used elsewhere in code - ThisFuncDoesntExist(); - } -}; - -public OnPluginStart() -{ -} - diff --git a/sourcepawn/compiler/tests/fail-methodmap-missing-method.txt b/sourcepawn/compiler/tests/fail-methodmap-missing-method.txt deleted file mode 100644 index e68fb927..00000000 --- a/sourcepawn/compiler/tests/fail-methodmap-missing-method.txt +++ /dev/null @@ -1 +0,0 @@ -(6) : error 017: undefined symbol "ThisFuncDoesntExist" diff --git a/sourcepawn/compiler/tests/fail-mismatch-on-implicit-this.sp b/sourcepawn/compiler/tests/fail-mismatch-on-implicit-this.sp deleted file mode 100644 index 00de8236..00000000 --- a/sourcepawn/compiler/tests/fail-mismatch-on-implicit-this.sp +++ /dev/null @@ -1,9 +0,0 @@ -native CloseHandle(HandleEgg:handle); - -methodmap Handle { - public Close() = CloseHandle; -}; - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/fail-mismatch-on-implicit-this.txt b/sourcepawn/compiler/tests/fail-mismatch-on-implicit-this.txt deleted file mode 100644 index aedab634..00000000 --- a/sourcepawn/compiler/tests/fail-mismatch-on-implicit-this.txt +++ /dev/null @@ -1 +0,0 @@ -method must have a first argument compatible with the methodmap type (Handle) diff --git a/sourcepawn/compiler/tests/fail-missing-arg-comma.sp b/sourcepawn/compiler/tests/fail-missing-arg-comma.sp deleted file mode 100644 index 9e56d2a3..00000000 --- a/sourcepawn/compiler/tests/fail-missing-arg-comma.sp +++ /dev/null @@ -1,4 +0,0 @@ -stock void Function( float array1[ 3 ] float array2[ 3 ] ) -{ - -} diff --git a/sourcepawn/compiler/tests/fail-missing-arg-comma.txt b/sourcepawn/compiler/tests/fail-missing-arg-comma.txt deleted file mode 100644 index 418e8963..00000000 --- a/sourcepawn/compiler/tests/fail-missing-arg-comma.txt +++ /dev/null @@ -1 +0,0 @@ -(1) : error 001: expected token: ")", but found "-identifier-" diff --git a/sourcepawn/compiler/tests/fail-multi-tag-on-implicit-this.sp b/sourcepawn/compiler/tests/fail-multi-tag-on-implicit-this.sp deleted file mode 100644 index f2b6dc74..00000000 --- a/sourcepawn/compiler/tests/fail-multi-tag-on-implicit-this.sp +++ /dev/null @@ -1,9 +0,0 @@ -native CloseHandle({Handle, Egg}:handle); - -methodmap Handle { - public Close() = CloseHandle; -}; - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/fail-multi-tag-on-implicit-this.txt b/sourcepawn/compiler/tests/fail-multi-tag-on-implicit-this.txt deleted file mode 100644 index aedab634..00000000 --- a/sourcepawn/compiler/tests/fail-multi-tag-on-implicit-this.txt +++ /dev/null @@ -1 +0,0 @@ -method must have a first argument compatible with the methodmap type (Handle) diff --git a/sourcepawn/compiler/tests/fail-new-with-no-constructor.sp b/sourcepawn/compiler/tests/fail-new-with-no-constructor.sp deleted file mode 100644 index 51580179..00000000 --- a/sourcepawn/compiler/tests/fail-new-with-no-constructor.sp +++ /dev/null @@ -1,10 +0,0 @@ -methodmap Handle __nullable__ -{ - public native ~Handle(); -}; - -public t() -{ - Handle egg = new Handle(); - delete egg; -} diff --git a/sourcepawn/compiler/tests/fail-new-with-no-constructor.txt b/sourcepawn/compiler/tests/fail-new-with-no-constructor.txt deleted file mode 100644 index d0ac818f..00000000 --- a/sourcepawn/compiler/tests/fail-new-with-no-constructor.txt +++ /dev/null @@ -1 +0,0 @@ -(8) : error 172: methodmap 'Handle' does not have a constructor diff --git a/sourcepawn/compiler/tests/fail-new-with-no-methodmap.sp b/sourcepawn/compiler/tests/fail-new-with-no-methodmap.sp deleted file mode 100644 index 6d666f44..00000000 --- a/sourcepawn/compiler/tests/fail-new-with-no-methodmap.sp +++ /dev/null @@ -1,13 +0,0 @@ -methodmap Handle __nullable__ -{ - public native Handle(); - public native ~Handle(); -}; - -enum Crab {}; - -public t() -{ - Crab egg = new Crab(); - delete egg; -} diff --git a/sourcepawn/compiler/tests/fail-new-with-no-methodmap.txt b/sourcepawn/compiler/tests/fail-new-with-no-methodmap.txt deleted file mode 100644 index 27d51f00..00000000 --- a/sourcepawn/compiler/tests/fail-new-with-no-methodmap.txt +++ /dev/null @@ -1 +0,0 @@ -(11) : error 116: no methodmap or class was found for Crab diff --git a/sourcepawn/compiler/tests/fail-new-with-non-nullable.sp b/sourcepawn/compiler/tests/fail-new-with-non-nullable.sp deleted file mode 100644 index 95684f5d..00000000 --- a/sourcepawn/compiler/tests/fail-new-with-non-nullable.sp +++ /dev/null @@ -1,11 +0,0 @@ -methodmap Handle -{ - public native Handle(); - public native ~Handle(); -}; - -public t() -{ - Handle egg = new Handle(); - delete egg; -} diff --git a/sourcepawn/compiler/tests/fail-new-with-non-nullable.txt b/sourcepawn/compiler/tests/fail-new-with-non-nullable.txt deleted file mode 100644 index 812014e4..00000000 --- a/sourcepawn/compiler/tests/fail-new-with-non-nullable.txt +++ /dev/null @@ -1 +0,0 @@ -(9) : error 171: cannot use 'new' with non-object-like methodmap 'Handle' diff --git a/sourcepawn/compiler/tests/fail-newdecls.sp b/sourcepawn/compiler/tests/fail-newdecls.sp deleted file mode 100644 index 510eef99..00000000 --- a/sourcepawn/compiler/tests/fail-newdecls.sp +++ /dev/null @@ -1,15 +0,0 @@ -native int[] egg6(); -forward float[] egg7(); -new void crab4; - -void bad(int[] yam[] = {1}) -{ -} - -forward void OnPluginStart(); - -public int OnPluginStart() -{ -} - - diff --git a/sourcepawn/compiler/tests/fail-newdecls.txt b/sourcepawn/compiler/tests/fail-newdecls.txt deleted file mode 100644 index 8259b01d..00000000 --- a/sourcepawn/compiler/tests/fail-newdecls.txt +++ /dev/null @@ -1,5 +0,0 @@ -(1) : error 141: natives, forwards, and public functions cannot return arrays -(2) : error 141: natives, forwards, and public functions cannot return arrays -(3) : error 143: new-style declarations should not have "new" -(5) : error 121: cannot specify array dimensions on both type and name -(9) : error 025: function heading differs from prototype diff --git a/sourcepawn/compiler/tests/fail-no-tag-on-implicit-this.sp b/sourcepawn/compiler/tests/fail-no-tag-on-implicit-this.sp deleted file mode 100644 index df7b09f1..00000000 --- a/sourcepawn/compiler/tests/fail-no-tag-on-implicit-this.sp +++ /dev/null @@ -1,9 +0,0 @@ -native CloseHandle(this); - -methodmap Handle { - public Close() = CloseHandle; -}; - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/fail-no-tag-on-implicit-this.txt b/sourcepawn/compiler/tests/fail-no-tag-on-implicit-this.txt deleted file mode 100644 index aedab634..00000000 --- a/sourcepawn/compiler/tests/fail-no-tag-on-implicit-this.txt +++ /dev/null @@ -1 +0,0 @@ -method must have a first argument compatible with the methodmap type (Handle) diff --git a/sourcepawn/compiler/tests/fail-nullable-needs-new.sp b/sourcepawn/compiler/tests/fail-nullable-needs-new.sp deleted file mode 100644 index 6c09a80a..00000000 --- a/sourcepawn/compiler/tests/fail-nullable-needs-new.sp +++ /dev/null @@ -1,11 +0,0 @@ -methodmap Handle __nullable__ -{ - public native Handle(); - public native ~Handle(); -}; - -public t() -{ - Handle egg = Handle(); - delete egg; -} diff --git a/sourcepawn/compiler/tests/fail-nullable-needs-new.txt b/sourcepawn/compiler/tests/fail-nullable-needs-new.txt deleted file mode 100644 index 701fb593..00000000 --- a/sourcepawn/compiler/tests/fail-nullable-needs-new.txt +++ /dev/null @@ -1 +0,0 @@ -(9) : error 170: creating new object 'Handle' requires using 'new' before its constructor diff --git a/sourcepawn/compiler/tests/fail-old-decl-new-types.sp b/sourcepawn/compiler/tests/fail-old-decl-new-types.sp deleted file mode 100644 index deaf3c96..00000000 --- a/sourcepawn/compiler/tests/fail-old-decl-new-types.sp +++ /dev/null @@ -1,8 +0,0 @@ -methodmap X { - public native Float X(); - public native String Z(); - public native T:Z(); -} - -public main() { -} diff --git a/sourcepawn/compiler/tests/fail-old-decl-new-types.txt b/sourcepawn/compiler/tests/fail-old-decl-new-types.txt deleted file mode 100644 index 371fe020..00000000 --- a/sourcepawn/compiler/tests/fail-old-decl-new-types.txt +++ /dev/null @@ -1,3 +0,0 @@ -type "Float" should be "float" in new-style declarations -type "String" should be "char" in new-style declarations -methodmap and class signatures must use new-style type declarations diff --git a/sourcepawn/compiler/tests/fail-property-bad-return-type.sp b/sourcepawn/compiler/tests/fail-property-bad-return-type.sp deleted file mode 100644 index 9bbf7cfe..00000000 --- a/sourcepawn/compiler/tests/fail-property-bad-return-type.sp +++ /dev/null @@ -1,12 +0,0 @@ -native GetCrab(Crab:crab); - -methodmap Crab { - property float Blah { - public get() = GetCrab; - } -} - -public main() { - new Crab:crab = Crab:5; - new x = crab.Blah; -} diff --git a/sourcepawn/compiler/tests/fail-property-bad-return-type.txt b/sourcepawn/compiler/tests/fail-property-bad-return-type.txt deleted file mode 100644 index d9f58f58..00000000 --- a/sourcepawn/compiler/tests/fail-property-bad-return-type.txt +++ /dev/null @@ -1 +0,0 @@ -getter must have the same return type as property Crab (float) diff --git a/sourcepawn/compiler/tests/fail-property-bad-return-value.txt b/sourcepawn/compiler/tests/fail-property-bad-return-value.txt deleted file mode 100644 index 80e10d93..00000000 --- a/sourcepawn/compiler/tests/fail-property-bad-return-value.txt +++ /dev/null @@ -1 +0,0 @@ -(4) : warning 213: tag mismatch diff --git a/sourcepawn/compiler/tests/fail-property-bad-this-type.sp b/sourcepawn/compiler/tests/fail-property-bad-this-type.sp deleted file mode 100644 index 8567e7fc..00000000 --- a/sourcepawn/compiler/tests/fail-property-bad-this-type.sp +++ /dev/null @@ -1,12 +0,0 @@ -native Float:GetCrab(); - -methodmap Crab { - property float Blah { - public get() = GetCrab(); - } -} - -public main() { - new Crab:crab = Crab:5; - new x = crab.Blah; -} diff --git a/sourcepawn/compiler/tests/fail-property-bad-this-type.txt b/sourcepawn/compiler/tests/fail-property-bad-this-type.txt deleted file mode 100644 index e23c2488..00000000 --- a/sourcepawn/compiler/tests/fail-property-bad-this-type.txt +++ /dev/null @@ -1 +0,0 @@ -method must have a first argument compatible with the methodmap type (Crab) diff --git a/sourcepawn/compiler/tests/fail-ref-on-implicit-this.sp b/sourcepawn/compiler/tests/fail-ref-on-implicit-this.sp deleted file mode 100644 index be718f1f..00000000 --- a/sourcepawn/compiler/tests/fail-ref-on-implicit-this.sp +++ /dev/null @@ -1,9 +0,0 @@ -native CloseHandle(&Handle:this); - -methodmap Handle { - public Close() = CloseHandle; -}; - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/fail-ref-on-implicit-this.txt b/sourcepawn/compiler/tests/fail-ref-on-implicit-this.txt deleted file mode 100644 index aedab634..00000000 --- a/sourcepawn/compiler/tests/fail-ref-on-implicit-this.txt +++ /dev/null @@ -1 +0,0 @@ -method must have a first argument compatible with the methodmap type (Handle) diff --git a/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.sp b/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.sp deleted file mode 100644 index 0ac7b42b..00000000 --- a/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.sp +++ /dev/null @@ -1,23 +0,0 @@ -native Float:float(x); -native Float:FloatMul(Float:oper1, Float:oper2); - -stock Float:operator*(Float:oper1, oper2) -{ - return FloatMul(oper1, float(oper2)); -} - -native Float:GetRandomFloat(); - -enum _:Rocketeer { - bool:bActivated, - iRockets[20] -}; - -public OnPluginStart() -{ - decl Float:fAngles[3]; - - fAngles[0] = GetRandomFloat() * 360; - fAngles[1] = GetRandomFloat() * 360; - fAngles[2] = GetRandomFloat() * 360; -} diff --git a/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.txt b/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.txt deleted file mode 100644 index e04c048c..00000000 --- a/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.txt +++ /dev/null @@ -1 +0,0 @@ -(11) : error 169: cannot tag an enum as implicit-int diff --git a/sourcepawn/compiler/tests/fail-this-outside-method.sp b/sourcepawn/compiler/tests/fail-this-outside-method.sp deleted file mode 100644 index ec7a9081..00000000 --- a/sourcepawn/compiler/tests/fail-this-outside-method.sp +++ /dev/null @@ -1,3 +0,0 @@ -public OnPluginStart() { - return this; -} diff --git a/sourcepawn/compiler/tests/fail-this-outside-method.txt b/sourcepawn/compiler/tests/fail-this-outside-method.txt deleted file mode 100644 index 34791c58..00000000 --- a/sourcepawn/compiler/tests/fail-this-outside-method.txt +++ /dev/null @@ -1 +0,0 @@ -(2) : error 166: cannot use 'this' outside of a methodmap method or property diff --git a/sourcepawn/compiler/tests/ok-any-in-newdecl.sp b/sourcepawn/compiler/tests/ok-any-in-newdecl.sp deleted file mode 100644 index adf6b802..00000000 --- a/sourcepawn/compiler/tests/ok-any-in-newdecl.sp +++ /dev/null @@ -1,3 +0,0 @@ -public x(any y) -{ -} diff --git a/sourcepawn/compiler/tests/ok-bad-int-cast.sp b/sourcepawn/compiler/tests/ok-bad-int-cast.sp deleted file mode 100644 index d3185535..00000000 --- a/sourcepawn/compiler/tests/ok-bad-int-cast.sp +++ /dev/null @@ -1,4 +0,0 @@ -public main() -{ - new class = int:5; -} diff --git a/sourcepawn/compiler/tests/ok-base-dtor.sp b/sourcepawn/compiler/tests/ok-base-dtor.sp deleted file mode 100644 index aab98556..00000000 --- a/sourcepawn/compiler/tests/ok-base-dtor.sp +++ /dev/null @@ -1,15 +0,0 @@ -native Handle:CreateHandle(count); -native CloseHandle(Handle:handle); - -methodmap Handle { - public Handle() = CreateHandle; - public ~Handle() = CloseHandle; -}; - -methodmap Crab < Handle { -}; - -public main() { - new Crab:crab; - delete crab; -} diff --git a/sourcepawn/compiler/tests/ok-base-type-as-thistag.sp b/sourcepawn/compiler/tests/ok-base-type-as-thistag.sp deleted file mode 100644 index 53b67f53..00000000 --- a/sourcepawn/compiler/tests/ok-base-type-as-thistag.sp +++ /dev/null @@ -1,14 +0,0 @@ -native CloseHandle(Handle:handle); - -methodmap Handle { -}; - -methodmap Crab < Handle { - public Close() = CloseHandle; -}; - -public main() -{ - new Crab:x; - x.Close(); -} diff --git a/sourcepawn/compiler/tests/ok-call-static-method.sp b/sourcepawn/compiler/tests/ok-call-static-method.sp deleted file mode 100644 index 19a887ea..00000000 --- a/sourcepawn/compiler/tests/ok-call-static-method.sp +++ /dev/null @@ -1,12 +0,0 @@ -native printnum(t); - -methodmap X -{ - public static int GetThing() { - return 10; - } -} - -public main() { - printnum(X.GetThing()); -} diff --git a/sourcepawn/compiler/tests/ok-chaining.sp b/sourcepawn/compiler/tests/ok-chaining.sp deleted file mode 100644 index 3a8849d2..00000000 --- a/sourcepawn/compiler/tests/ok-chaining.sp +++ /dev/null @@ -1,38 +0,0 @@ -methodmap Duck -{ - property bool MyProp - { - public get() { - return true; - } - } -}; - -public bool OnPluginStart() -{ - Duck duck = GiveMeADuck(); - - // no compile errors or warnings - if (duck.MyProp) - { - } - - // error 001: expected token: ")", but found "." - // error 029: invalid expression, assumed zero - // error 017: undefined symbol "MyProp" - if (GiveMeADuck().MyProp) - { - } - - // warning 213: tag mismatch - // error 001: expected token: ";", but found "." - // error 029: invalid expression, assumed zero - // error 017: undefined symbol "MyProp" - bool prop = GiveMeADuck().MyProp; - return prop -} - -stock Duck GiveMeADuck() -{ - return Duck:1; -} diff --git a/sourcepawn/compiler/tests/ok-class-arg.sp b/sourcepawn/compiler/tests/ok-class-arg.sp deleted file mode 100644 index 1454638c..00000000 --- a/sourcepawn/compiler/tests/ok-class-arg.sp +++ /dev/null @@ -1,7 +0,0 @@ -f(const char[] class) -{ -} - -public OnPluginStart() -{ -} diff --git a/sourcepawn/compiler/tests/ok-coerce-on-operators.sp b/sourcepawn/compiler/tests/ok-coerce-on-operators.sp deleted file mode 100644 index 643124dd..00000000 --- a/sourcepawn/compiler/tests/ok-coerce-on-operators.sp +++ /dev/null @@ -1,18 +0,0 @@ -enum Handle { - INVALID_HANDLE, -}; - -methodmap Handle {}; -methodmap ArrayList < Handle {}; - -public void MyCommand() -{ - ArrayList myList; - if (INVALID_HANDLE == myList) - { - } - if (myList == INVALID_HANDLE) - { - } -} - diff --git a/sourcepawn/compiler/tests/ok-ctor-dtor.sp b/sourcepawn/compiler/tests/ok-ctor-dtor.sp deleted file mode 100644 index cb5cfbdc..00000000 --- a/sourcepawn/compiler/tests/ok-ctor-dtor.sp +++ /dev/null @@ -1,12 +0,0 @@ -native Handle:CreateHandle(count); -native CloseHandle(Handle:handle); - -methodmap Handle { - public Handle() = CreateHandle; - public ~Handle() = CloseHandle; -}; - -public main() { - new Handle:handle = Handle(3); - delete handle; -} diff --git a/sourcepawn/compiler/tests/ok-dynamic-char.sp b/sourcepawn/compiler/tests/ok-dynamic-char.sp deleted file mode 100644 index 88c7b281..00000000 --- a/sourcepawn/compiler/tests/ok-dynamic-char.sp +++ /dev/null @@ -1,5 +0,0 @@ - -public OnPluginStart() -{ - char[] x = new char[500]; -} diff --git a/sourcepawn/compiler/tests/ok-for-newdecl.sp b/sourcepawn/compiler/tests/ok-for-newdecl.sp deleted file mode 100644 index 575151d2..00000000 --- a/sourcepawn/compiler/tests/ok-for-newdecl.sp +++ /dev/null @@ -1,5 +0,0 @@ -public OnPluginStart() -{ - for (bool x; x;) { - } -} diff --git a/sourcepawn/compiler/tests/ok-inheritance.sp b/sourcepawn/compiler/tests/ok-inheritance.sp deleted file mode 100644 index d7a27aa3..00000000 --- a/sourcepawn/compiler/tests/ok-inheritance.sp +++ /dev/null @@ -1,14 +0,0 @@ -native CloseHandle(Handle:handle); - -methodmap Handle { - public Close() = CloseHandle; -}; - -methodmap Crab < Handle { -}; - -public main() -{ - new Crab:x; - x.Close(); -} diff --git a/sourcepawn/compiler/tests/ok-inline-methods.sp b/sourcepawn/compiler/tests/ok-inline-methods.sp deleted file mode 100644 index 86945bf0..00000000 --- a/sourcepawn/compiler/tests/ok-inline-methods.sp +++ /dev/null @@ -1,13 +0,0 @@ -methodmap Crab { - public Crab(int n) { - return Crab:n; - } - public int Value() { - return _:this; - } -}; - -public main() { - new Crab:crab = Crab(5); - return crab.Value(); -} diff --git a/sourcepawn/compiler/tests/ok-inline-natives.sp b/sourcepawn/compiler/tests/ok-inline-natives.sp deleted file mode 100644 index 733d816b..00000000 --- a/sourcepawn/compiler/tests/ok-inline-natives.sp +++ /dev/null @@ -1,17 +0,0 @@ -methodmap Handle { - public native Handle(); - public native ~Handle(); - public native Handle Clone(); - public native int Size(); - public native float SizeF(); - public native bool Ok(x, y, z); -}; - -public main() { - new Handle:handle = Handle(); - handle.Clone(); - new x = handle.Size(); - new Float:f = handle.SizeF(); - new bool:b = handle.Ok(1, 2, 3); - delete handle; -} diff --git a/sourcepawn/compiler/tests/ok-local-dynamic-bool.sp b/sourcepawn/compiler/tests/ok-local-dynamic-bool.sp deleted file mode 100644 index 454d68b0..00000000 --- a/sourcepawn/compiler/tests/ok-local-dynamic-bool.sp +++ /dev/null @@ -1,5 +0,0 @@ -public int main() -{ - bool[] egg = new bool[10]; -} - diff --git a/sourcepawn/compiler/tests/ok-method-on-const.sp b/sourcepawn/compiler/tests/ok-method-on-const.sp deleted file mode 100644 index ca2092e5..00000000 --- a/sourcepawn/compiler/tests/ok-method-on-const.sp +++ /dev/null @@ -1,14 +0,0 @@ -native CloseHandle(Handle:handle); - -enum Handle { - INVALID_HANDLE = 0, -}; - -methodmap Handle { - public Close() = CloseHandle; -}; - -public main() -{ - INVALID_HANDLE.Close(); -} diff --git a/sourcepawn/compiler/tests/ok-method-on-constref.sp b/sourcepawn/compiler/tests/ok-method-on-constref.sp deleted file mode 100644 index 6a147215..00000000 --- a/sourcepawn/compiler/tests/ok-method-on-constref.sp +++ /dev/null @@ -1,16 +0,0 @@ -native CloseHandle(Handle:handle); - -methodmap Handle { - public Close() = CloseHandle; -}; - -f(const &Handle:x) -{ - x.Close() -} - -public main() -{ - new Handle:x; - f(x) -} diff --git a/sourcepawn/compiler/tests/ok-method-on-element.sp b/sourcepawn/compiler/tests/ok-method-on-element.sp deleted file mode 100644 index 1feca10e..00000000 --- a/sourcepawn/compiler/tests/ok-method-on-element.sp +++ /dev/null @@ -1,11 +0,0 @@ -native CloseHandle(Handle:handle); - -methodmap Handle { - public Close() = CloseHandle; -}; - -public main() -{ - new Handle:x[2]; - x[1].Close(); -} diff --git a/sourcepawn/compiler/tests/ok-method-on-ref.sp b/sourcepawn/compiler/tests/ok-method-on-ref.sp deleted file mode 100644 index b28af861..00000000 --- a/sourcepawn/compiler/tests/ok-method-on-ref.sp +++ /dev/null @@ -1,16 +0,0 @@ -native CloseHandle(Handle:handle); - -methodmap Handle { - public Close() = CloseHandle; -}; - -f(&Handle:x) -{ - x.Close() -} - -public main() -{ - new Handle:x; - f(x) -} diff --git a/sourcepawn/compiler/tests/ok-method-on-scalar.sp b/sourcepawn/compiler/tests/ok-method-on-scalar.sp deleted file mode 100644 index 007b5a98..00000000 --- a/sourcepawn/compiler/tests/ok-method-on-scalar.sp +++ /dev/null @@ -1,13 +0,0 @@ -native CloneHandle(Handle:handle); -native CloseHandle(Handle:handle); - -methodmap Handle { - public Clone() = CloneHandle; - public Close() = CloseHandle; -}; - -public main() -{ - new Handle:x; - x.Close(); -} diff --git a/sourcepawn/compiler/tests/ok-methodmap-semis.sp b/sourcepawn/compiler/tests/ok-methodmap-semis.sp deleted file mode 100644 index dfff64c8..00000000 --- a/sourcepawn/compiler/tests/ok-methodmap-semis.sp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma semicolon 1 - -native IsValidEntity(entity); - -methodmap Entity -{ - public Entity(const char[] className) { - return Entity:CreateEntityByName(className); - } - - property bool IsValid { - public get() { - return IsValidEntity(_:this); - } - } -}; - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/ok-new-decl-args.sp b/sourcepawn/compiler/tests/ok-new-decl-args.sp deleted file mode 100644 index c2e25745..00000000 --- a/sourcepawn/compiler/tests/ok-new-decl-args.sp +++ /dev/null @@ -1,44 +0,0 @@ -stock A(int n) -{ -} - -stock B(int n[10]) -{ -} - -stock C(int[] n) -{ -} - -enum E1: { -} -enum E2 { -} - -stock D(E1 t) -{ -} - -stock E(E2 t) -{ -} - -stock F(const int n[10]) { -} - -stock G(int& n) -{ -} - -public main() -{ - new x[10] - new t - A(1) - B(x) - C(x) - D(E1:5) - E(E2:5) - F(x) - G(t) -} diff --git a/sourcepawn/compiler/tests/ok-new-dynamic-array-syntax.sp b/sourcepawn/compiler/tests/ok-new-dynamic-array-syntax.sp deleted file mode 100644 index ef3f8ac4..00000000 --- a/sourcepawn/compiler/tests/ok-new-dynamic-array-syntax.sp +++ /dev/null @@ -1,10 +0,0 @@ -native printnum(num); - -public main() -{ - new x = 4; - new y = 8; - int[][] v = new int[4][8]; - v[2][3] = 9; - printnum(v[2][3]); -} diff --git a/sourcepawn/compiler/tests/ok-new-with-nullable-methodmap.sp b/sourcepawn/compiler/tests/ok-new-with-nullable-methodmap.sp deleted file mode 100644 index 700d5c9f..00000000 --- a/sourcepawn/compiler/tests/ok-new-with-nullable-methodmap.sp +++ /dev/null @@ -1,15 +0,0 @@ -native void printnum(int num); - -methodmap Handle __nullable__ -{ - public Handle() { - return Handle:2; - } - public native ~Handle(); -}; - -public main() -{ - Handle egg = new Handle(); - printnum(_:egg); -} diff --git a/sourcepawn/compiler/tests/ok-newdecl-const.sp b/sourcepawn/compiler/tests/ok-newdecl-const.sp deleted file mode 100644 index 4a013a49..00000000 --- a/sourcepawn/compiler/tests/ok-newdecl-const.sp +++ /dev/null @@ -1,12 +0,0 @@ -// both fine -const MY_CONST = 1; -const Float:FLOAT_CONST = 1.0; - -// error 020: invalid symbol name "" -const int MY_INT_COST = 1; -// error 001: expected token: "=", but found "-identifier-" -const float MY_FLOAT_CONST = 1.0; - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/ok-newdecls.sp b/sourcepawn/compiler/tests/ok-newdecls.sp deleted file mode 100644 index 581e0131..00000000 --- a/sourcepawn/compiler/tests/ok-newdecls.sp +++ /dev/null @@ -1,50 +0,0 @@ -native egg(); -native void egg2(); -native int egg3(); -native bool egg4(); -native bool:egg5(); - -new crab; -new crab2 = 5; -bool crab3 = true; -int crab4 = 6; -new crab5[] = {1, 2, 3}; -bool crab7[] = {false, true, true} -char crab8[] = "hello" - -native float operator*(float oper1, float oper2) = FloatMul; - -forward void OnPluginStart(); - -public int Crab() -{ -} - -public float Crab2() -{ -} - -public Crab3() -{ -} - -stock char[] Crab4() -{ - new String:t[5] = "egg"; - return t; -} - -new yam, yam2, yam3 -new Float:ham, bool:ham2; -int cram, cram2, cram3; -new cram4[] = {1, 2}, cram5[] = {3, 4, 7} -int cram6[] = {1, 2}, cram7[] = {3, 4, 7} - -public OnPluginStart() -{ - new String:t[5]; - t = Crab4(); - cram4[0] = 2 - cram5[2] = 2 - cram7[2] = 2 -} diff --git a/sourcepawn/compiler/tests/ok-null-compare.sp b/sourcepawn/compiler/tests/ok-null-compare.sp deleted file mode 100644 index 044c0bfd..00000000 --- a/sourcepawn/compiler/tests/ok-null-compare.sp +++ /dev/null @@ -1,19 +0,0 @@ -enum Handle: -{ -} - -methodmap Handle __nullable__ -{ -} - -methodmap StringMap < Handle -{ -} - -native Log(const char[] fmt, any:...) - -public main() -{ - StringMap f - Log("hello %d", f != null) -} diff --git a/sourcepawn/compiler/tests/ok-properties.sp b/sourcepawn/compiler/tests/ok-properties.sp deleted file mode 100644 index 52b26b51..00000000 --- a/sourcepawn/compiler/tests/ok-properties.sp +++ /dev/null @@ -1,29 +0,0 @@ -native Float:GetCrabWhat(Crab:crab); - -methodmap Crab { - public Crab(int n) { - return Crab:n; - } - property Crab Yams { - public get() { - return Crab:5; - } - } - property int Blah { - public native get(); - } - property float What { - public get() = GetCrabWhat; - } -} - -print(n) { - return n -} - -public main() { - new Crab:crab = Crab(10); - print(_:crab.Yams.Yams.Yams) - print(crab.Blah); - print(_:crab.What); -} diff --git a/sourcepawn/compiler/tests/ok-reparse-delete.sp b/sourcepawn/compiler/tests/ok-reparse-delete.sp deleted file mode 100644 index 6886cdea..00000000 --- a/sourcepawn/compiler/tests/ok-reparse-delete.sp +++ /dev/null @@ -1,12 +0,0 @@ -methodmap Handle { - public native ~Handle(); -} - -stock Crab(Handle h) -{ - delete h; -} - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/ok-setter-no-getter.sp b/sourcepawn/compiler/tests/ok-setter-no-getter.sp deleted file mode 100644 index 86c28fd6..00000000 --- a/sourcepawn/compiler/tests/ok-setter-no-getter.sp +++ /dev/null @@ -1,12 +0,0 @@ -methodmap Crab -{ - property int X { - public native set(int value); - } -} - -public main() -{ - Crab crab; - crab.X = 12; -} diff --git a/sourcepawn/compiler/tests/ok-static-stock.sp b/sourcepawn/compiler/tests/ok-static-stock.sp deleted file mode 100644 index 73516697..00000000 --- a/sourcepawn/compiler/tests/ok-static-stock.sp +++ /dev/null @@ -1,13 +0,0 @@ -static stock Blah() -{ -} - -static stock void Blah2() -{ -} - -public main() -{ - Blah(); - Blah2(); -} diff --git a/sourcepawn/compiler/tests/ok-static-stocks-1.sp b/sourcepawn/compiler/tests/ok-static-stocks-1.sp deleted file mode 100644 index bf523238..00000000 --- a/sourcepawn/compiler/tests/ok-static-stocks-1.sp +++ /dev/null @@ -1,5 +0,0 @@ -static stock const X = 5; -stock static const Y = 6; - -public main() -{} diff --git a/sourcepawn/compiler/tests/ok-static-stocks-2.sp b/sourcepawn/compiler/tests/ok-static-stocks-2.sp deleted file mode 100644 index 2ced8743..00000000 --- a/sourcepawn/compiler/tests/ok-static-stocks-2.sp +++ /dev/null @@ -1,7 +0,0 @@ -static stock const X = 5; -stock static const Y = 6; - -public main() -{ - return X + Y; -} diff --git a/sourcepawn/compiler/tests/ok-trailing-comma-in-literal.sp b/sourcepawn/compiler/tests/ok-trailing-comma-in-literal.sp deleted file mode 100644 index e1876f6d..00000000 --- a/sourcepawn/compiler/tests/ok-trailing-comma-in-literal.sp +++ /dev/null @@ -1,20 +0,0 @@ - -new String:oldArray[][] = -{ - "string", - "string2", -}; - -char newArray[][] = -{ - "another string", - "more strings", -}; - -native Print( const String:string[] ); - -public OnPluginStart() -{ - Print( oldArray[ 0 ] ); - Print( newArray[ 0 ] ); -} diff --git a/sourcepawn/compiler/tests/ok-typed-vararg-in-new-function.sp b/sourcepawn/compiler/tests/ok-typed-vararg-in-new-function.sp deleted file mode 100644 index 3be4a63f..00000000 --- a/sourcepawn/compiler/tests/ok-typed-vararg-in-new-function.sp +++ /dev/null @@ -1,7 +0,0 @@ -methodmap X { - public native void egg(any ...); -}; - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/ok-typedef-func-chars.sp b/sourcepawn/compiler/tests/ok-typedef-func-chars.sp deleted file mode 100644 index 36f8753c..00000000 --- a/sourcepawn/compiler/tests/ok-typedef-func-chars.sp +++ /dev/null @@ -1,26 +0,0 @@ -enum Action: {} -functag public Action:OldFuncTag( String:someString[128] ); -typedef NewFuncTag = function Action ( char someString[128] ); - -native UseOldFuncTag( OldFuncTag func ); -native UseNewFuncTag( NewFuncTag func ); - -public OnPluginStart() -{ - // fine - UseOldFuncTag( MyOldFunc ); - // also fine - UseOldFuncTag( MyNewFunc ); - - // error 100: function prototypes do not match - UseNewFuncTag( MyOldFunc ); - // error 100: function prototypes do not match - UseNewFuncTag( MyNewFunc ); -} - -public Action:MyOldFunc( String:someString[128] ) -{ -} -public Action MyNewFunc( char someString[128] ) -{ -} diff --git a/sourcepawn/compiler/tests/ok-use-aliased-constructor.sp b/sourcepawn/compiler/tests/ok-use-aliased-constructor.sp deleted file mode 100644 index 1dca0339..00000000 --- a/sourcepawn/compiler/tests/ok-use-aliased-constructor.sp +++ /dev/null @@ -1,12 +0,0 @@ -native Handle:CreateHandle(); - -methodmap Handle __nullable__ -{ - public native Handle() = CreateHandle; - public native ~Handle(); -}; - -public main() -{ - CreateHandle(); -} diff --git a/sourcepawn/compiler/tests/ok-varargs.sp b/sourcepawn/compiler/tests/ok-varargs.sp deleted file mode 100644 index 8361c066..00000000 --- a/sourcepawn/compiler/tests/ok-varargs.sp +++ /dev/null @@ -1,7 +0,0 @@ -stock MyFormat( const String:formatString[], ... ) -{ -} - -public main() -{ -} diff --git a/sourcepawn/compiler/tests/ok-view-int-as-float.sp b/sourcepawn/compiler/tests/ok-view-int-as-float.sp deleted file mode 100644 index 74ce7a1d..00000000 --- a/sourcepawn/compiler/tests/ok-view-int-as-float.sp +++ /dev/null @@ -1,3 +0,0 @@ -public float egg() { - return view_as(10); -} diff --git a/sourcepawn/compiler/tests/runtests.py b/sourcepawn/compiler/tests/runtests.py deleted file mode 100644 index ac4c7c30..00000000 --- a/sourcepawn/compiler/tests/runtests.py +++ /dev/null @@ -1,83 +0,0 @@ -# vim: set ts=4 sw=4 tw=99 et: -import os, sys -import argparse -import subprocess - -def run_tests(args): - testdir = os.path.dirname(os.path.abspath(__file__)) - tests = [] - for filename in os.listdir(testdir): - base, ext = os.path.splitext(filename) - if ext == '.sp': - tests += [base] - - failed = False - - for test in tests: - if test.startswith('fail-'): - kind = 'fail' - elif test.startswith('warn-'): - kind = 'warn' - elif test.startswith('ok-'): - kind = 'pass' - - try: - argv = [os.path.abspath(args.spcomp), os.path.join(testdir, test + '.sp')] - p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = p.communicate() - stdout = stdout.decode('utf-8') - stderr = stderr.decode('utf-8') - - smx_path = test + '.smx' - compiled = os.path.exists(smx_path) - if compiled: - os.unlink(smx_path) - - status = 'ok' - if compiled and kind == 'fail': - status = 'fail' - elif not compiled and kind != 'fail': - status = 'fail' - - fails = [] - if status == 'ok' and kind != 'pass': - lines = [] - with open(os.path.join(testdir, test + '.txt')) as fp: - for line in fp: - lines.append(line.strip()) - for line in lines: - if line not in stdout: - fails += [ - 'Expected to find text in stdout: >>>\n', - line, - '<<<\n', - ] - break - - if status == 'fail' or len(fails): - print('Test {0} ... FAIL'.format(test)) - failed = True - sys.stderr.write('FAILED! Dumping stdout/stderr:\n') - sys.stderr.write(stdout) - sys.stderr.write(stderr) - for line in fails: - sys.stderr.write(line) - else: - print('Test {0} ... OK'.format(test)) - - except Exception as exn: - raise - sys.stderr.write('FAILED! {0}\n'.format(exn.message)) - - if failed: - sys.stderr.write('One or more tests failed!\n') - sys.exit(1) - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('spcomp', type=str, help='Path to spcomp') - args = parser.parse_args() - run_tests(args) - -if __name__ == '__main__': - main() diff --git a/sourcepawn/compiler/tests/warn-bad-upcast.sp b/sourcepawn/compiler/tests/warn-bad-upcast.sp deleted file mode 100644 index a76438db..00000000 --- a/sourcepawn/compiler/tests/warn-bad-upcast.sp +++ /dev/null @@ -1,15 +0,0 @@ -native CloseHandle(Handle:handle); - -methodmap Handle { - public Close() = CloseHandle; -}; - -methodmap Crab { -}; - -public main() -{ - new Crab:x; - new Handle:y; - x = y; -} diff --git a/sourcepawn/compiler/tests/warn-bad-upcast.txt b/sourcepawn/compiler/tests/warn-bad-upcast.txt deleted file mode 100644 index bdb238a4..00000000 --- a/sourcepawn/compiler/tests/warn-bad-upcast.txt +++ /dev/null @@ -1 +0,0 @@ -tag mismatch diff --git a/sourcepawn/compiler/tests/warn-oldstyle-cast.sp b/sourcepawn/compiler/tests/warn-oldstyle-cast.sp deleted file mode 100644 index 5f6c899c..00000000 --- a/sourcepawn/compiler/tests/warn-oldstyle-cast.sp +++ /dev/null @@ -1,18 +0,0 @@ - -#pragma newdecls required - -enum MyType:{}; - -native void Print(MyType value); -native void PrintF(float value); - -public void main() -{ - int val = 2; - MyType otherVal = MyType:val; - - float value2 = Float:val; - - Print(otherVal); - PrintF(value2); -} diff --git a/sourcepawn/compiler/tests/warn-oldstyle-cast.txt b/sourcepawn/compiler/tests/warn-oldstyle-cast.txt deleted file mode 100644 index 21696a51..00000000 --- a/sourcepawn/compiler/tests/warn-oldstyle-cast.txt +++ /dev/null @@ -1,2 +0,0 @@ -(12) : warning 240: 'MyType:' is an old-style tag operation; use view_as(expression) instead -(14) : warning 240: 'Float:' is an old-style tag operation; use view_as(expression) instead diff --git a/sourcepawn/compiler/tokenbuffer.h b/sourcepawn/compiler/tokenbuffer.h deleted file mode 100644 index ce3fa168..00000000 --- a/sourcepawn/compiler/tokenbuffer.h +++ /dev/null @@ -1,35 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -#ifndef _sourcepawn_compiler_token_stream_h_ -#define _sourcepawn_compiler_token_stream_h_ - -typedef struct { - int line; - int col; -} token_pos_t; - -typedef struct { - int id; - int value; - char str[sLINEMAX + 1]; - size_t len; - token_pos_t start; - token_pos_t end; -} full_token_t; - -#define MAX_TOKEN_DEPTH 4 - -typedef struct { - // Total number of tokens parsed. - int num_tokens; - - // Number of tokens that we've rewound back to. - int depth; - - // Most recently fetched token. - int cursor; - - // Circular token buffer. - full_token_t tokens[MAX_TOKEN_DEPTH]; -} token_buffer_t; - -#endif // _sourcepawn_compiler_token_stream_h_ diff --git a/sourcepawn/compiler/version.rc b/sourcepawn/compiler/version.rc deleted file mode 100644 index c9f1d7c4..00000000 --- a/sourcepawn/compiler/version.rc +++ /dev/null @@ -1,52 +0,0 @@ -#include -#if defined WIN32 || defined _WIN32 || defined __WIN32__ -# include -#else -# include -#endif -#include - -AppIcon ICON "pawn.ico" - -/* Version information - * - * All strings MUST have an explicit \0. See the Windows SDK documentation - * for details on version information and the VERSIONINFO structure. - */ - -#define VERSIONNAME "smcomp.exe\0" -#define VERSIONDESCRIPTION "SourcePawn Compiler\0" -#define VERSIONPRODUCTNAME "smcomp\0" - -VS_VERSION_INFO VERSIONINFO -FILEVERSION SM_VERSION_FILE -PRODUCTVERSION SM_VERSION_FILE -FILEFLAGSMASK 0x0000003FL -FILEFLAGS 0 -#if defined(WIN32) - FILEOS VOS__WINDOWS32 -#else - FILEOS VOS__WINDOWS16 -#endif -FILETYPE VFT_DLL -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - BEGIN - VALUE "CompanyName", "(C)1998-2006 ITB CompuPhase, AlliedModders LLC\0" - VALUE "FileDescription", VERSIONDESCRIPTION - VALUE "FileVersion", SM_VERSION_STRING - VALUE "InternalName", VERSIONNAME - VALUE "LegalCopyright", "(C)1998-2006 ITB CompuPhase, AlliedModders LLC\0" - VALUE "OriginalFilename", VERSIONNAME - VALUE "ProductName", VERSIONPRODUCTNAME - VALUE "ProductVersion", SM_VERSION_STRING - END - END - - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END diff --git a/sourcepawn/compiler/zlib/adler32.c b/sourcepawn/compiler/zlib/adler32.c deleted file mode 100644 index f201d670..00000000 --- a/sourcepawn/compiler/zlib/adler32.c +++ /dev/null @@ -1,149 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -#define BASE 65521UL /* largest prime smaller than 65536 */ -#define NMAX 5552 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - -#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} -#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); -#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); -#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); -#define DO16(buf) DO8(buf,0); DO8(buf,8); - -/* use NO_DIVIDE if your processor does not do division in hardware */ -#ifdef NO_DIVIDE -# define MOD(a) \ - do { \ - if (a >= (BASE << 16)) a -= (BASE << 16); \ - if (a >= (BASE << 15)) a -= (BASE << 15); \ - if (a >= (BASE << 14)) a -= (BASE << 14); \ - if (a >= (BASE << 13)) a -= (BASE << 13); \ - if (a >= (BASE << 12)) a -= (BASE << 12); \ - if (a >= (BASE << 11)) a -= (BASE << 11); \ - if (a >= (BASE << 10)) a -= (BASE << 10); \ - if (a >= (BASE << 9)) a -= (BASE << 9); \ - if (a >= (BASE << 8)) a -= (BASE << 8); \ - if (a >= (BASE << 7)) a -= (BASE << 7); \ - if (a >= (BASE << 6)) a -= (BASE << 6); \ - if (a >= (BASE << 5)) a -= (BASE << 5); \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ - if (a >= BASE) a -= BASE; \ - } while (0) -# define MOD4(a) \ - do { \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ - if (a >= BASE) a -= BASE; \ - } while (0) -#else -# define MOD(a) a %= BASE -# define MOD4(a) a %= BASE -#endif - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - unsigned long sum2; - unsigned n; - - /* split Adler-32 into component sums */ - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (len == 1) { - adler += buf[0]; - if (adler >= BASE) - adler -= BASE; - sum2 += adler; - if (sum2 >= BASE) - sum2 -= BASE; - return adler | (sum2 << 16); - } - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (buf == Z_NULL) - return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (len < 16) { - while (len--) { - adler += *buf++; - sum2 += adler; - } - if (adler >= BASE) - adler -= BASE; - MOD4(sum2); /* only added so many BASE's */ - return adler | (sum2 << 16); - } - - /* do length NMAX blocks -- requires just one modulo operation */ - while (len >= NMAX) { - len -= NMAX; - n = NMAX / 16; /* NMAX is divisible by 16 */ - do { - DO16(buf); /* 16 sums unrolled */ - buf += 16; - } while (--n); - MOD(adler); - MOD(sum2); - } - - /* do remaining bytes (less than NMAX, still just one modulo) */ - if (len) { /* avoid modulos if none remaining */ - while (len >= 16) { - len -= 16; - DO16(buf); - buf += 16; - } - while (len--) { - adler += *buf++; - sum2 += adler; - } - MOD(adler); - MOD(sum2); - } - - /* return recombined sums */ - return adler | (sum2 << 16); -} - -/* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ - unsigned long sum1; - unsigned long sum2; - unsigned rem; - - /* the derivation of this formula is left as an exercise for the reader */ - rem = (unsigned)(len2 % BASE); - sum1 = adler1 & 0xffff; - sum2 = rem * sum1; - MOD(sum2); - sum1 += (adler2 & 0xffff) + BASE - 1; - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; - if (sum1 > BASE) sum1 -= BASE; - if (sum1 > BASE) sum1 -= BASE; - if (sum2 > (BASE << 1)) sum2 -= (BASE << 1); - if (sum2 > BASE) sum2 -= BASE; - return sum1 | (sum2 << 16); -} diff --git a/sourcepawn/compiler/zlib/compress.c b/sourcepawn/compiler/zlib/compress.c deleted file mode 100644 index d37e84f5..00000000 --- a/sourcepawn/compiler/zlib/compress.c +++ /dev/null @@ -1,79 +0,0 @@ -/* compress.c -- compress a memory buffer - * Copyright (C) 1995-2003 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least 0.1% larger than sourceLen plus - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ - z_stream stream; - int err; - - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; -#ifdef MAXSEG_64K - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; -#endif - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - - err = deflateInit(&stream, level); - if (err != Z_OK) return err; - - err = deflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - deflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = deflateEnd(&stream); - return err; -} - -/* =========================================================================== - */ -int ZEXPORT compress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); -} - -/* =========================================================================== - If the default memLevel or windowBits for deflateInit() is changed, then - this function needs to be updated. - */ -uLong ZEXPORT compressBound (sourceLen) - uLong sourceLen; -{ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; -} diff --git a/sourcepawn/compiler/zlib/crc32.c b/sourcepawn/compiler/zlib/crc32.c deleted file mode 100644 index 5e8c44be..00000000 --- a/sourcepawn/compiler/zlib/crc32.c +++ /dev/null @@ -1,424 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Thanks to Rodney Brown for his contribution of faster - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing - * tables for updating the shift register in one step with three exclusive-ors - * instead of four steps with four exclusive-ors. This results in about a - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. - */ - -/* @(#) $Id$ */ - -/* - Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore - protection on the static variables used to control the first-use generation - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should - first call get_crc_table() to initialize the tables before allowing more than - one thread to use crc32(). - */ - -#include -#ifdef MAKECRCH -# include -# ifndef DYNAMIC_CRC_TABLE -# define DYNAMIC_CRC_TABLE -# endif /* !DYNAMIC_CRC_TABLE */ -#endif /* MAKECRCH */ - -#include "zutil.h" /* for STDC and FAR definitions */ - -#define local static - -/* Find a four-byte integer type for crc32_little() and crc32_big(). */ -#ifndef NOBYFOUR -# ifdef STDC /* need ANSI C limits.h to determine sizes */ -# include -# define BYFOUR -# if (UINT_MAX == 0xffffffffUL) - typedef unsigned int u4; -# else -# if (ULONG_MAX == 0xffffffffUL) - typedef unsigned long u4; -# else -# if (USHRT_MAX == 0xffffffffUL) - typedef unsigned short u4; -# else -# undef BYFOUR /* can't find a four-byte integer type! */ -# endif -# endif -# endif -# endif /* STDC */ -#endif /* !NOBYFOUR */ - -/* Definitions for doing the crc four data bytes at a time. */ -#ifdef BYFOUR -# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ - (((w)&0xff00)<<8)+(((w)&0xff)<<24)) - local unsigned long crc32_little OF((unsigned long, - const unsigned char FAR *, unsigned)); - local unsigned long crc32_big OF((unsigned long, - const unsigned char FAR *, unsigned)); -# define TBLS 8 -#else -# define TBLS 1 -#endif /* BYFOUR */ - -/* Local functions for crc concatenation */ -local unsigned long gf2_matrix_times OF((unsigned long *mat, - unsigned long vec)); -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); - -#ifdef DYNAMIC_CRC_TABLE - -local volatile int crc_table_empty = 1; -local unsigned long FAR crc_table[TBLS][256]; -local void make_crc_table OF((void)); -#ifdef MAKECRCH - local void write_table OF((FILE *, const unsigned long FAR *)); -#endif /* MAKECRCH */ -/* - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The first table is simply the CRC of all possible eight bit values. This is - all the information needed to generate CRCs on data a byte at a time for all - combinations of CRC register values and incoming bytes. The remaining tables - allow for word-at-a-time CRC calculation for both big-endian and little- - endian machines, where a word is four bytes. -*/ -local void make_crc_table() -{ - unsigned long c; - int n, k; - unsigned long poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static volatile int first = 1; /* flag to limit concurrent making */ - static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* See if another task is already doing this (not thread-safe, but better - than nothing -- significantly reduces duration of vulnerability in - case the advice about DYNAMIC_CRC_TABLE is ignored) */ - if (first) { - first = 0; - - /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0UL; - for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) - poly |= 1UL << (31 - p[n]); - - /* generate a crc for every 8-bit value */ - for (n = 0; n < 256; n++) { - c = (unsigned long)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[0][n] = c; - } - -#ifdef BYFOUR - /* generate crc for each value followed by one, two, and three zeros, - and then the byte reversal of those as well as the first table */ - for (n = 0; n < 256; n++) { - c = crc_table[0][n]; - crc_table[4][n] = REV(c); - for (k = 1; k < 4; k++) { - c = crc_table[0][c & 0xff] ^ (c >> 8); - crc_table[k][n] = c; - crc_table[k + 4][n] = REV(c); - } - } -#endif /* BYFOUR */ - - crc_table_empty = 0; - } - else { /* not first */ - /* wait for the other guy to finish (not efficient, but rare) */ - while (crc_table_empty) - ; - } - -#ifdef MAKECRCH - /* write out CRC tables to crc32.h */ - { - FILE *out; - - out = fopen("crc32.h", "w"); - if (out == NULL) return; - fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); - fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const unsigned long FAR "); - fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); - write_table(out, crc_table[0]); -# ifdef BYFOUR - fprintf(out, "#ifdef BYFOUR\n"); - for (k = 1; k < 8; k++) { - fprintf(out, " },\n {\n"); - write_table(out, crc_table[k]); - } - fprintf(out, "#endif\n"); -# endif /* BYFOUR */ - fprintf(out, " }\n};\n"); - fclose(out); - } -#endif /* MAKECRCH */ -} - -#ifdef MAKECRCH -local void write_table(out, table) - FILE *out; - const unsigned long FAR *table; -{ - int n; - - for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], - n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); -} -#endif /* MAKECRCH */ - -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables of CRC-32s of all single-byte values, made by make_crc_table(). - */ -#include "crc32.h" -#endif /* DYNAMIC_CRC_TABLE */ - -/* ========================================================================= - * This function can be used by asm versions of crc32() - */ -const unsigned long FAR * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - return (const unsigned long FAR *)crc_table; -} - -/* ========================================================================= */ -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 - -/* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - if (buf == Z_NULL) return 0UL; - -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - -#ifdef BYFOUR - if (sizeof(void *) == sizeof(ptrdiff_t)) { - u4 endian; - - endian = 1; - if (*((unsigned char *)(&endian))) - return crc32_little(crc, buf, len); - else - return crc32_big(crc, buf, len); - } -#endif /* BYFOUR */ - crc = crc ^ 0xffffffffUL; - while (len >= 8) { - DO8; - len -= 8; - } - if (len) do { - DO1; - } while (--len); - return crc ^ 0xffffffffUL; -} - -#ifdef BYFOUR - -/* ========================================================================= */ -#define DOLIT4 c ^= *buf4++; \ - c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ - crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 - -/* ========================================================================= */ -local unsigned long crc32_little(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register u4 c; - register const u4 FAR *buf4; - - c = (u4)crc; - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - len--; - } - - buf4 = (const u4 FAR *)(const void FAR *)buf; - while (len >= 32) { - DOLIT32; - len -= 32; - } - while (len >= 4) { - DOLIT4; - len -= 4; - } - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - } while (--len); - c = ~c; - return (unsigned long)c; -} - -/* ========================================================================= */ -#define DOBIG4 c ^= *++buf4; \ - c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ - crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 - -/* ========================================================================= */ -local unsigned long crc32_big(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register u4 c; - register const u4 FAR *buf4; - - c = REV((u4)crc); - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - len--; - } - - buf4 = (const u4 FAR *)(const void FAR *)buf; - buf4--; - while (len >= 32) { - DOBIG32; - len -= 32; - } - while (len >= 4) { - DOBIG4; - len -= 4; - } - buf4++; - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - } while (--len); - c = ~c; - return (unsigned long)(REV(c)); -} - -#endif /* BYFOUR */ - -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ - -/* ========================================================================= */ -local unsigned long gf2_matrix_times(mat, vec) - unsigned long *mat; - unsigned long vec; -{ - unsigned long sum; - - sum = 0; - while (vec) { - if (vec & 1) - sum ^= *mat; - vec >>= 1; - mat++; - } - return sum; -} - -/* ========================================================================= */ -local void gf2_matrix_square(square, mat) - unsigned long *square; - unsigned long *mat; -{ - int n; - - for (n = 0; n < GF2_DIM; n++) - square[n] = gf2_matrix_times(mat, mat[n]); -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ - int n; - unsigned long row; - unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ - unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ - - /* degenerate case */ - if (len2 == 0) - return crc1; - - /* put operator for one zero bit in odd */ - odd[0] = 0xedb88320L; /* CRC-32 polynomial */ - row = 1; - for (n = 1; n < GF2_DIM; n++) { - odd[n] = row; - row <<= 1; - } - - /* put operator for two zero bits in even */ - gf2_matrix_square(even, odd); - - /* put operator for four zero bits in odd */ - gf2_matrix_square(odd, even); - - /* apply len2 zeros to crc1 (first square will put the operator for one - zero byte, eight zero bits, in even) */ - do { - /* apply zeros operator for this bit of len2 */ - gf2_matrix_square(even, odd); - if (len2 & 1) - crc1 = gf2_matrix_times(even, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - if (len2 == 0) - break; - - /* another iteration of the loop with odd and even swapped */ - gf2_matrix_square(odd, even); - if (len2 & 1) - crc1 = gf2_matrix_times(odd, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - } while (len2 != 0); - - /* return combined crc */ - crc1 ^= crc2; - return crc1; -} diff --git a/sourcepawn/compiler/zlib/crc32.h b/sourcepawn/compiler/zlib/crc32.h deleted file mode 100644 index 5de49bc9..00000000 --- a/sourcepawn/compiler/zlib/crc32.h +++ /dev/null @@ -1,441 +0,0 @@ -/* crc32.h -- tables for rapid CRC calculation - * Generated automatically by crc32.c - */ - -local const unsigned long FAR crc_table[TBLS][256] = -{ - { - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, - 0x2d02ef8dUL -#ifdef BYFOUR - }, - { - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, - 0x9324fd72UL - }, - { - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, - 0xbe9834edUL - }, - { - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, - 0xde0506f1UL - }, - { - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, - 0x8def022dUL - }, - { - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, - 0x72fd2493UL - }, - { - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, - 0xed3498beUL - }, - { - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, - 0xf10605deUL -#endif - } -}; diff --git a/sourcepawn/compiler/zlib/deflate.c b/sourcepawn/compiler/zlib/deflate.c deleted file mode 100644 index f58dee25..00000000 --- a/sourcepawn/compiler/zlib/deflate.c +++ /dev/null @@ -1,1737 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many people for bug reports and testing. - * - * REFERENCES - * - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in http://www.ietf.org/rfc/rfc1951.txt - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - */ - -/* @(#) $Id$ */ - -#include -#include "deflate.h" - -const char deflate_copyright[] = - " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* =========================================================================== - * Function prototypes. - */ -typedef enum { - need_more, /* block not completed, need more input or more output */ - block_done, /* block flush performed */ - finish_started, /* finish started, need only more output at next deflate */ - finish_done /* finish done, accept no more input or output */ -} block_state; - -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); -/* Compression function. Returns the block state after the call. */ - -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); -#ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -#ifndef FASTEST -#ifdef ASMV - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); -#else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); -#endif -#endif -local uInt longest_match_fast OF((deflate_state *s, IPos cur_match)); - -#ifdef DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); -#endif - -/* =========================================================================== - * Local data - */ - -#define NIL 0 -/* Tail of hash chains */ - -#ifndef TOO_FAR -# define TOO_FAR 4096 -#endif -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ -typedef struct config_s { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; - compress_func func; -} config; - -#ifdef FASTEST -local const config configuration_table[2] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ -#else -local const config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ -/* 2 */ {4, 5, 16, 8, deflate_fast}, -/* 3 */ {4, 6, 32, 32, deflate_fast}, - -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ -/* 5 */ {8, 16, 32, 32, deflate_slow}, -/* 6 */ {8, 16, 128, 128, deflate_slow}, -/* 7 */ {8, 32, 128, 256, deflate_slow}, -/* 8 */ {32, 128, 258, 1024, deflate_slow}, -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ -#endif - -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different - * meaning. - */ - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -#ifndef NO_DUMMY_DECL -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ -#endif - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. - */ -#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) - - -/* =========================================================================== - * Insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - * If this file is compiled with -DFASTEST, the compression level is forced - * to 1, and no hash chains are maintained. - * IN assertion: all calls to to INSERT_STRING are made with consecutive - * input characters and the first MIN_MATCH bytes of str are valid - * (except for the last MIN_MATCH-1 bytes of the input file). - */ -#ifdef FASTEST -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#else -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#endif - -/* =========================================================================== - * Initialize the hash table (avoiding 64K overflow for 16 bit systems). - * prev[] will be initialized on the fly. - */ -#define CLEAR_HASH(s) \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); - -/* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); - /* To do: ignore strm->next_in if we use it as window */ -} - -/* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ - deflate_state *s; - int wrap = 1; - static const char my_version[] = ZLIB_VERSION; - - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - - if (version == Z_NULL || version[0] != my_version[0] || - stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; - } - if (strm == Z_NULL) return Z_STREAM_ERROR; - - strm->msg = Z_NULL; - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - - if (windowBits < 0) { /* suppress zlib wrapper */ - wrap = 0; - windowBits = -windowBits; - } -#ifdef GZIP - else if (windowBits > 15) { - wrap = 2; /* write gzip wrapper instead */ - windowBits -= 16; - } -#endif - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - - s->wrap = wrap; - s->gzhead = Z_NULL; - s->w_bits = windowBits; - s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; - - s->hash_bits = memLevel + 7; - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); - - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); - - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); - - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || - s->pending_buf == Z_NULL) { - s->status = FINISH_STATE; - strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); - deflateEnd (strm); - return Z_MEM_ERROR; - } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; - - s->level = level; - s->strategy = strategy; - s->method = (Byte)method; - - return deflateReset(strm); -} - -/* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ - deflate_state *s; - uInt length = dictLength; - uInt n; - IPos hash_head = 0; - - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || - strm->state->wrap == 2 || - (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) - return Z_STREAM_ERROR; - - s = strm->state; - if (s->wrap) - strm->adler = adler32(strm->adler, dictionary, dictLength); - - if (length < MIN_MATCH) return Z_OK; - if (length > MAX_DIST(s)) { - length = MAX_DIST(s); - dictionary += dictLength - length; /* use the tail of the dictionary */ - } - zmemcpy(s->window, dictionary, length); - s->strstart = length; - s->block_start = (long)length; - - /* Insert all strings in the hash table (except for the last two bytes). - * s->lookahead stays null, so s->ins_h will be recomputed at the next - * call of fill_window. - */ - s->ins_h = s->window[0]; - UPDATE_HASH(s, s->ins_h, s->window[1]); - for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); - } - if (hash_head) hash_head = 0; /* to make compiler happy */ - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { - return Z_STREAM_ERROR; - } - - strm->total_in = strm->total_out = 0; - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ - strm->data_type = Z_UNKNOWN; - - s = (deflate_state *)strm->state; - s->pending = 0; - s->pending_out = s->pending_buf; - - if (s->wrap < 0) { - s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ - } - s->status = s->wrap ? INIT_STATE : BUSY_STATE; - strm->adler = -#ifdef GZIP - s->wrap == 2 ? crc32(0L, Z_NULL, 0) : -#endif - adler32(0L, Z_NULL, 0); - s->last_flush = Z_NO_FLUSH; - - _tr_init(s); - lm_init(s); - - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateSetHeader (strm, head) - z_streamp strm; - gz_headerp head; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - if (strm->state->wrap != 2) return Z_STREAM_ERROR; - strm->state->gzhead = head; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflatePrime (strm, bits, value) - z_streamp strm; - int bits; - int value; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - strm->state->bi_valid = bits; - strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ - deflate_state *s; - compress_func func; - int err = Z_OK; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if (func != configuration_table[level].func && strm->total_in != 0) { - /* Flush the last buffer: */ - err = deflate(strm, Z_PARTIAL_FLUSH); - } - if (s->level != level) { - s->level = level; - s->max_lazy_match = configuration_table[level].max_lazy; - s->good_match = configuration_table[level].good_length; - s->nice_match = configuration_table[level].nice_length; - s->max_chain_length = configuration_table[level].max_chain; - } - s->strategy = strategy; - return err; -} - -/* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - s->good_match = good_length; - s->max_lazy_match = max_lazy; - s->nice_match = nice_length; - s->max_chain_length = max_chain; - return Z_OK; -} - -/* ========================================================================= - * For the default windowBits of 15 and memLevel of 8, this function returns - * a close to exact, as well as small, upper bound on the compressed size. - * They are coded as constants here for a reason--if the #define's are - * changed, then this function needs to be changed as well. The return - * value for 15 and 8 only works for those exact settings. - * - * For any setting other than those defaults for windowBits and memLevel, - * the value returned is a conservative worst case for the maximum expansion - * resulting from using fixed blocks instead of stored blocks, which deflate - * can emit on compressed data for some combinations of the parameters. - * - * This function could be more sophisticated to provide closer upper bounds - * for every combination of windowBits and memLevel, as well as wrap. - * But even the conservative upper bound of about 14% expansion does not - * seem onerous for output buffer allocation. - */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ - deflate_state *s; - uLong destLen; - - /* conservative upper bound */ - destLen = sourceLen + - ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11; - - /* if can't get parameters, return conservative bound */ - if (strm == Z_NULL || strm->state == Z_NULL) - return destLen; - - /* if not default parameters, return conservative bound */ - s = strm->state; - if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return destLen; - - /* default settings: return tight bound for that case */ - return compressBound(sourceLen); -} - -/* ========================================================================= - * Put a short in the pending buffer. The 16-bit value is put in MSB order. - * IN assertion: the stream state is correct and there is enough room in - * pending_buf. - */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; -{ - put_byte(s, (Byte)(b >> 8)); - put_byte(s, (Byte)(b & 0xff)); -} - -/* ========================================================================= - * Flush as much pending output as possible. All deflate() output goes - * through this function so some applications may wish to modify it - * to avoid allocating a large strm->next_out buffer and copying into it. - * (See also read_buf()). - */ -local void flush_pending(strm) - z_streamp strm; -{ - unsigned len = strm->state->pending; - - if (len > strm->avail_out) len = strm->avail_out; - if (len == 0) return; - - zmemcpy(strm->next_out, strm->state->pending_out, len); - strm->next_out += len; - strm->state->pending_out += len; - strm->total_out += len; - strm->avail_out -= len; - strm->state->pending -= len; - if (strm->state->pending == 0) { - strm->state->pending_out = strm->state->pending_buf; - } -} - -/* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; -{ - int old_flush; /* value of flush param for previous deflate call */ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_FINISH || flush < 0) { - return Z_STREAM_ERROR; - } - s = strm->state; - - if (strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { - ERR_RETURN(strm, Z_STREAM_ERROR); - } - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - - s->strm = strm; /* just in case */ - old_flush = s->last_flush; - s->last_flush = flush; - - /* Write the header */ - if (s->status == INIT_STATE) { -#ifdef GZIP - if (s->wrap == 2) { - strm->adler = crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (s->gzhead == NULL) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s->status = BUSY_STATE; - } - else { - put_byte(s, (s->gzhead->text ? 1 : 0) + - (s->gzhead->hcrc ? 2 : 0) + - (s->gzhead->extra == Z_NULL ? 0 : 4) + - (s->gzhead->name == Z_NULL ? 0 : 8) + - (s->gzhead->comment == Z_NULL ? 0 : 16) - ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != NULL) { - put_byte(s, s->gzhead->extra_len & 0xff); - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); - } - if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, - s->pending); - s->gzindex = 0; - s->status = EXTRA_STATE; - } - } - else -#endif - { - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags; - - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) - level_flags = 0; - else if (s->level < 6) - level_flags = 1; - else if (s->level == 6) - level_flags = 2; - else - level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - s->status = BUSY_STATE; - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = adler32(0L, Z_NULL, 0); - } - } -#ifdef GZIP - if (s->status == EXTRA_STATE) { - if (s->gzhead->extra != NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - - while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) - break; - } - put_byte(s, s->gzhead->extra[s->gzindex]); - s->gzindex++; - } - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (s->gzindex == s->gzhead->extra_len) { - s->gzindex = 0; - s->status = NAME_STATE; - } - } - else - s->status = NAME_STATE; - } - if (s->status == NAME_STATE) { - if (s->gzhead->name != NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->name[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) { - s->gzindex = 0; - s->status = COMMENT_STATE; - } - } - else - s->status = COMMENT_STATE; - } - if (s->status == COMMENT_STATE) { - if (s->gzhead->comment != NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->comment[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) - s->status = HCRC_STATE; - } - else - s->status = HCRC_STATE; - } - if (s->status == HCRC_STATE) { - if (s->gzhead->hcrc) { - if (s->pending + 2 > s->pending_buf_size) - flush_pending(strm); - if (s->pending + 2 <= s->pending_buf_size) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - strm->adler = crc32(0L, Z_NULL, 0); - s->status = BUSY_STATE; - } - } - else - s->status = BUSY_STATE; - } -#endif - - /* Flush as much pending output as possible */ - if (s->pending != 0) { - flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s->last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm->avail_in == 0 && flush <= old_flush && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* Start a new block or continue the current one. - */ - if (strm->avail_in != 0 || s->lookahead != 0 || - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { - block_state bstate; - - bstate = (*(configuration_table[s->level].func))(s, flush); - - if (bstate == finish_started || bstate == finish_done) { - s->status = FINISH_STATE; - } - if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate == block_done) { - if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); - } else { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush == Z_FULL_FLUSH) { - CLEAR_HASH(s); /* forget history */ - } - } - flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - Assert(strm->avail_out > 0, "bug2"); - - if (flush != Z_FINISH) return Z_OK; - if (s->wrap <= 0) return Z_STREAM_END; - - /* Write the trailer */ -#ifdef GZIP - if (s->wrap == 2) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); - put_byte(s, (Byte)(strm->total_in & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); - } - else -#endif - { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; -} - -/* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; -{ - int status; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - - status = strm->state->status; - if (status != INIT_STATE && - status != EXTRA_STATE && - status != NAME_STATE && - status != COMMENT_STATE && - status != HCRC_STATE && - status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, strm->state->pending_buf); - TRY_FREE(strm, strm->state->head); - TRY_FREE(strm, strm->state->prev); - TRY_FREE(strm, strm->state->window); - - ZFREE(strm, strm->state); - strm->state = Z_NULL; - - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; -} - -/* ========================================================================= - * Copy the source state to the destination state. - * To simplify the source, this is not supported for 16-bit MSDOS (which - * doesn't have enough memory anyway to duplicate compression states). - */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; -{ -#ifdef MAXSEG_64K - return Z_STREAM_ERROR; -#else - deflate_state *ds; - deflate_state *ss; - ushf *overlay; - - - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { - return Z_STREAM_ERROR; - } - - ss = source->state; - - zmemcpy(dest, source, sizeof(z_stream)); - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - zmemcpy(ds, ss, sizeof(deflate_state)); - ds->strm = dest; - - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); - ds->pending_buf = (uchf *) overlay; - - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || - ds->pending_buf == Z_NULL) { - deflateEnd (dest); - return Z_MEM_ERROR; - } - /* following zmemcpy do not work for 16-bit MSDOS */ - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); - - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; - - ds->l_desc.dyn_tree = ds->dyn_ltree; - ds->d_desc.dyn_tree = ds->dyn_dtree; - ds->bl_desc.dyn_tree = ds->bl_tree; - - return Z_OK; -#endif /* MAXSEG_64K */ -} - -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local int read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, strm->next_in, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, strm->next_in, len); - } -#endif - zmemcpy(buf, strm->next_in, len); - strm->next_in += len; - strm->total_in += len; - - return (int)len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init (s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifndef FASTEST -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -#endif -} - -#ifndef FASTEST -/* =========================================================================== - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - * OUT assertion: the match length is not greater than s->lookahead. - */ -#ifndef ASMV -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or - * match.S. The code will be functionally equivalent. - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - unsigned chain_length = s->max_chain_length;/* max hash chain length */ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - int best_len = s->prev_length; /* best match length so far */ - int nice_match = s->nice_match; /* stop if match long enough */ - IPos limit = s->strstart > (IPos)MAX_DIST(s) ? - s->strstart - (IPos)MAX_DIST(s) : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - Posf *prev = s->prev; - uInt wmask = s->w_mask; - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; - register ush scan_start = *(ushf*)scan; - register ush scan_end = *(ushf*)(scan+best_len-1); -#else - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - register Byte scan_end1 = scan[best_len-1]; - register Byte scan_end = scan[best_len]; -#endif - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - /* Do not waste too much time if we already have a good match: */ - if (s->prev_length >= s->good_match) { - chain_length >>= 2; - } - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - do { - Assert(cur_match < s->strstart, "no future"); - match = s->window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2. Note that the checks below - * for insufficient lookahead only occur occasionally for performance - * reasons. Therefore uninitialized memory will be accessed, and - * conditional jumps will be made that depend on those values. - * However the length of the match is limited to the lookahead, so - * the output of deflate is not affected by the uninitialized values. - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ushf*)(match+best_len-1) != scan_end || - *(ushf*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - Assert(scan[2] == match[2], "scan[2]?"); - scan++, match++; - do { - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - s->match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ushf*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & wmask]) > limit - && --chain_length != 0); - - if ((uInt)best_len <= s->lookahead) return (uInt)best_len; - return s->lookahead; -} -#endif /* ASMV */ -#endif /* FASTEST */ - -/* --------------------------------------------------------------------------- - * Optimized version for level == 1 or strategy == Z_RLE only - */ -local uInt longest_match_fast(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - Assert(cur_match < s->strstart, "no future"); - - match = s->window + cur_match; - - /* Return failure if the match length is less than 2: - */ - if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match += 2; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - - if (len < MIN_MATCH) return MIN_MATCH - 1; - - s->match_start = cur_match; - return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; -} - -#ifdef DEBUG -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); - do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); - z_error("invalid match"); - } - if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(s, start, match, length) -#endif /* DEBUG */ - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - register unsigned n, m; - register Posf *p; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize+MAX_DIST(s)) { - - zmemcpy(s->window, s->window+wsize, (unsigned)wsize); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - - /* Slide the hash table (could be avoided with 32 bit values - at the expense of memory usage). We slide even when level == 0 - to keep the hash table consistent if we switch back to level > 0 - later. (Using level 0 permanently is not an optimal usage of - zlib, so we don't care about this pathological case.) - */ - /* %%% avoid this when Z_RLE */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); - - n = wsize; -#ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); -#endif - more += wsize; - } - if (s->strm->avail_in == 0) return; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead >= MIN_MATCH) { - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK_ONLY(s, eof) { \ - _tr_flush_block(s, (s->block_start >= 0L ? \ - (charf *)&s->window[(unsigned)s->block_start] : \ - (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (eof)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, eof) { \ - FLUSH_BLOCK_ONLY(s, eof); \ - if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ -} - -/* =========================================================================== - * Copy without compression as much as possible from the input stream, return - * the current block state. - * This function does not insert new strings in the dictionary since - * uncompressible data is probably not useful. This function is used - * only for the level=0 compression option. - * NOTE: this function should be optimized to avoid extra copying from - * window to pending_buf. - */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited - * to pending_buf_size, and each stored block has a 5 byte header: - */ - ulg max_block_size = 0xffff; - ulg max_start; - - if (max_block_size > s->pending_buf_size - 5) { - max_block_size = s->pending_buf_size - 5; - } - - /* Copy as much as possible from input to output: */ - for (;;) { - /* Fill the window as much as possible: */ - if (s->lookahead <= 1) { - - Assert(s->strstart < s->w_size+MAX_DIST(s) || - s->block_start >= (long)s->w_size, "slide too late"); - - fill_window(s); - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; - - if (s->lookahead == 0) break; /* flush the current block */ - } - Assert(s->block_start >= 0L, "block gone"); - - s->strstart += s->lookahead; - s->lookahead = 0; - - /* Emit a stored block if pending_buf will be full: */ - max_start = s->block_start + max_block_size; - if (s->strstart == 0 || (ulg)s->strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s->lookahead = (uInt)(s->strstart - max_start); - s->strstart = (uInt)max_start; - FLUSH_BLOCK(s, 0); - } - /* Flush if we may have to slide, otherwise block_start may become - * negative and the data will be gone: - */ - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { - FLUSH_BLOCK(s, 0); - } - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -/* =========================================================================== - * Compress as much as possible from the input stream, return the current - * block state. - * This function does not perform lazy evaluation of matches and inserts - * new strings in the dictionary only for unmatched strings or for short - * matches. It is used only for the fast compression options. - */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ -#ifdef FASTEST - if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) || - (s->strategy == Z_RLE && s->strstart - hash_head == 1)) { - s->match_length = longest_match_fast (s, hash_head); - } -#else - if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { - s->match_length = longest_match (s, hash_head); - } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { - s->match_length = longest_match_fast (s, hash_head); - } -#endif - /* longest_match() or longest_match_fast() sets match_start */ - } - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->match_start, s->match_length); - - _tr_tally_dist(s, s->strstart - s->match_start, - s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ -#ifndef FASTEST - if (s->match_length <= s->max_insert_length && - s->lookahead >= MIN_MATCH) { - s->match_length--; /* string at strstart already in table */ - do { - s->strstart++; - INSERT_STRING(s, s->strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--s->match_length != 0); - s->strstart++; - } else -#endif - { - s->strstart += s->match_length; - s->match_length = 0; - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -#ifndef FASTEST -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* head of hash chain */ - int bflush; /* set if current block must be flushed */ - - /* Process the input block. */ - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - */ - s->prev_length = s->match_length, s->prev_match = s->match_start; - s->match_length = MIN_MATCH-1; - - if (hash_head != NIL && s->prev_length < s->max_lazy_match && - s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { - s->match_length = longest_match (s, hash_head); - } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { - s->match_length = longest_match_fast (s, hash_head); - } - /* longest_match() or longest_match_fast() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED -#if TOO_FAR <= 32767 - || (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR) -#endif - )) { - - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - s->match_length = MIN_MATCH-1; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - - check_match(s, s->strstart-1, s->prev_match, s->prev_length); - - _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not - * enough lookahead, the last two strings are not inserted in - * the hash table. - */ - s->lookahead -= s->prev_length-1; - s->prev_length -= 2; - do { - if (++s->strstart <= max_insert) { - INSERT_STRING(s, s->strstart, hash_head); - } - } while (--s->prev_length != 0); - s->match_available = 0; - s->match_length = MIN_MATCH-1; - s->strstart++; - - if (bflush) FLUSH_BLOCK(s, 0); - - } else if (s->match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - if (bflush) { - FLUSH_BLOCK_ONLY(s, 0); - } - s->strstart++; - s->lookahead--; - if (s->strm->avail_out == 0) return need_more; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - s->match_available = 1; - s->strstart++; - s->lookahead--; - } - } - Assert (flush != Z_NO_FLUSH, "no flush?"); - if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - s->match_available = 0; - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} -#endif /* FASTEST */ - -#if 0 -/* =========================================================================== - * For Z_RLE, simply look for runs of bytes, generate matches only of distance - * one. Do not maintain a hash table. (It will be regenerated if this run of - * deflate switches away from Z_RLE.) - */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - uInt run; /* length of run */ - uInt max; /* maximum length of run */ - uInt prev; /* byte at distance one to match */ - Bytef *scan; /* scan for end of run */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the longest encodable run. - */ - if (s->lookahead < MAX_MATCH) { - fill_window(s); - if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* See how many times the previous byte repeats */ - run = 0; - if (s->strstart > 0) { /* if there is a previous byte, that is */ - max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH; - scan = s->window + s->strstart - 1; - prev = *scan++; - do { - if (*scan++ != prev) - break; - } while (++run < max); - } - - /* Emit match if have run of MIN_MATCH or longer, else emit literal */ - if (run >= MIN_MATCH) { - check_match(s, s->strstart, s->strstart - 1, run); - _tr_tally_dist(s, 1, run - MIN_MATCH, bflush); - s->lookahead -= run; - s->strstart += run; - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} -#endif diff --git a/sourcepawn/compiler/zlib/deflate.h b/sourcepawn/compiler/zlib/deflate.h deleted file mode 100644 index 222c53e0..00000000 --- a/sourcepawn/compiler/zlib/deflate.h +++ /dev/null @@ -1,331 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-2004 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef DEFLATE_H -#define DEFLATE_H - -#include "zutil.h" - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer creation by deflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip encoding - should be left enabled. */ -#ifndef NO_GZIP -# define GZIP -#endif - -/* =========================================================================== - * Internal compression state. - */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define INIT_STATE 42 -#define EXTRA_STATE 69 -#define NAME_STATE 73 -#define COMMENT_STATE 91 -#define HCRC_STATE 103 -#define BUSY_STATE 113 -#define FINISH_STATE 666 -/* Stream status */ - - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data_s { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} FAR ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -typedef struct static_tree_desc_s static_tree_desc; - -typedef struct tree_desc_s { - ct_data *dyn_tree; /* the dynamic tree */ - int max_code; /* largest code with non zero frequency */ - static_tree_desc *stat_desc; /* the corresponding static tree */ -} FAR tree_desc; - -typedef ush Pos; -typedef Pos FAR Posf; -typedef unsigned IPos; - -/* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. IPos is used only for parameter passing. - */ - -typedef struct internal_state { - z_streamp strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - Bytef *pending_buf; /* output still pending */ - ulg pending_buf_size; /* size of pending_buf */ - Bytef *pending_out; /* next pending byte to output to the stream */ - uInt pending; /* nb of bytes in the pending buffer */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - gz_headerp gzhead; /* gzip header information to write */ - uInt gzindex; /* where in extra, name, or comment */ - Byte method; /* STORED (for zip only) or DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ - - /* used by deflate.c: */ - - uInt w_size; /* LZ77 window size (32K by default) */ - uInt w_bits; /* log2(w_size) (8..16) */ - uInt w_mask; /* w_size - 1 */ - - Bytef *window; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. Also, it limits - * the window size to 64K, which is quite useful on MSDOS. - * To do: use the user input buffer as sliding window. - */ - - ulg window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - Posf *prev; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - Posf *head; /* Heads of the hash chains or NIL. */ - - uInt ins_h; /* hash index of string to be inserted */ - uInt hash_size; /* number of elements in hash table */ - uInt hash_bits; /* log2(hash_size) */ - uInt hash_mask; /* hash_size-1 */ - - uInt hash_shift; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to supress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *l_buf; /* buffer for literals or lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - int last_eob_len; /* bit length of EOB code for last block */ - -#ifdef DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - - /* in trees.c */ -void _tr_init OF((deflate_state *s)); -int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); -void _tr_align OF((deflate_state *s)); -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); - -#define d_code(dist) \ - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never - * used. - */ - -#ifndef DEBUG -/* Inline versions of _tr_tally for speed: */ - -#if defined(GEN_TREES_H) || !defined(STDC) - extern uch _length_code[]; - extern uch _dist_code[]; -#else - extern const uch _length_code[]; - extern const uch _dist_code[]; -#endif - -# define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ - s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -# define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ - ush dist = (distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ - dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ - s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -#else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) -#endif - -#endif /* DEFLATE_H */ diff --git a/sourcepawn/compiler/zlib/gzio.c b/sourcepawn/compiler/zlib/gzio.c deleted file mode 100644 index 5e20a4aa..00000000 --- a/sourcepawn/compiler/zlib/gzio.c +++ /dev/null @@ -1,1026 +0,0 @@ -/* gzio.c -- IO on .gz files - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Compile this file with -DNO_GZCOMPRESS to avoid the compression code. - */ - -/* @(#) $Id$ */ - -#include - -#include "zutil.h" - -#ifdef NO_DEFLATE /* for compatibility with old definition */ -# define NO_GZCOMPRESS -#endif - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -#ifndef Z_BUFSIZE -# ifdef MAXSEG_64K -# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ -# else -# define Z_BUFSIZE 16384 -# endif -#endif -#ifndef Z_PRINTF_BUFSIZE -# define Z_PRINTF_BUFSIZE 4096 -#endif - -#ifdef __MVS__ -# pragma map (fdopen , "\174\174FDOPEN") - FILE *fdopen(int, const char *); -#endif - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern void free OF((voidpf ptr)); -#endif - -#define ALLOC(size) malloc(size) -#define TRYFREE(p) {if (p) free(p);} - -static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ - -/* gzip flag byte */ -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define RESERVED 0xE0 /* bits 5..7: reserved */ - -typedef struct gz_stream { - z_stream stream; - int z_err; /* error code for last stream operation */ - int z_eof; /* set if end of input file */ - FILE *file; /* .gz file */ - Byte *inbuf; /* input buffer */ - Byte *outbuf; /* output buffer */ - uLong crc; /* crc32 of uncompressed data */ - char *msg; /* error message */ - char *path; /* path name for debugging only */ - int transparent; /* 1 if input file is not a .gz file */ - char mode; /* 'w' or 'r' */ - z_off_t start; /* start of compressed data in file (header skipped) */ - z_off_t in; /* bytes into deflate or inflate */ - z_off_t out; /* bytes out of deflate or inflate */ - int back; /* one character push-back */ - int last; /* true if push-back is last character */ -} gz_stream; - - -local gzFile gz_open OF((const char *path, const char *mode, int fd)); -local int do_flush OF((gzFile file, int flush)); -local int get_byte OF((gz_stream *s)); -local void check_header OF((gz_stream *s)); -local int destroy OF((gz_stream *s)); -local void putLong OF((FILE *file, uLong x)); -local uLong getLong OF((gz_stream *s)); - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb"). The file is given either by file descriptor - or path name (if fd == -1). - gz_open returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). -*/ -local gzFile gz_open (path, mode, fd) - const char *path; - const char *mode; - int fd; -{ - int err; - int level = Z_DEFAULT_COMPRESSION; /* compression level */ - int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ - char *p = (char*)mode; - gz_stream *s; - char fmode[80]; /* copy of mode, without the compression level */ - char *m = fmode; - - if (!path || !mode) return Z_NULL; - - s = (gz_stream *)ALLOC(sizeof(gz_stream)); - if (!s) return Z_NULL; - - s->stream.zalloc = (alloc_func)0; - s->stream.zfree = (free_func)0; - s->stream.opaque = (voidpf)0; - s->stream.next_in = s->inbuf = Z_NULL; - s->stream.next_out = s->outbuf = Z_NULL; - s->stream.avail_in = s->stream.avail_out = 0; - s->file = NULL; - s->z_err = Z_OK; - s->z_eof = 0; - s->in = 0; - s->out = 0; - s->back = EOF; - s->crc = crc32(0L, Z_NULL, 0); - s->msg = NULL; - s->transparent = 0; - - s->path = (char*)ALLOC(strlen(path)+1); - if (s->path == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - strcpy(s->path, path); /* do this early for debugging */ - - s->mode = '\0'; - do { - if (*p == 'r') s->mode = 'r'; - if (*p == 'w' || *p == 'a') s->mode = 'w'; - if (*p >= '0' && *p <= '9') { - level = *p - '0'; - } else if (*p == 'f') { - strategy = Z_FILTERED; - } else if (*p == 'h') { - strategy = Z_HUFFMAN_ONLY; - } else if (*p == 'R') { - strategy = Z_RLE; - } else { - *m++ = *p; /* copy the mode */ - } - } while (*p++ && m != fmode + sizeof(fmode)); - if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; - - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - err = Z_STREAM_ERROR; -#else - err = deflateInit2(&(s->stream), level, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); - /* windowBits is passed < 0 to suppress zlib header */ - - s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); -#endif - if (err != Z_OK || s->outbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } else { - s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); - - err = inflateInit2(&(s->stream), -MAX_WBITS); - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are - * present after the compressed stream. - */ - if (err != Z_OK || s->inbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } - s->stream.avail_out = Z_BUFSIZE; - - errno = 0; - s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode); - - if (s->file == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - if (s->mode == 'w') { - /* Write a very simple .gz header: - */ - fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); - s->start = 10L; - /* We use 10L instead of ftell(s->file) to because ftell causes an - * fflush on some systems. This version of the library doesn't use - * start anyway in write mode, so this initialization is not - * necessary. - */ - } else { - check_header(s); /* skip the .gz header */ - s->start = ftell(s->file) - s->stream.avail_in; - } - - return (gzFile)s; -} - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. -*/ -gzFile ZEXPORT gzopen (path, mode) - const char *path; - const char *mode; -{ - return gz_open (path, mode, -1); -} - -/* =========================================================================== - Associate a gzFile with the file descriptor fd. fd is not dup'ed here - to mimic the behavio(u)r of fdopen. -*/ -gzFile ZEXPORT gzdopen (fd, mode) - int fd; - const char *mode; -{ - char name[46]; /* allow for up to 128-bit integers */ - - if (fd < 0) return (gzFile)Z_NULL; - sprintf(name, "", fd); /* for debugging */ - - return gz_open (name, mode, fd); -} - -/* =========================================================================== - * Update the compression level and strategy - */ -int ZEXPORT gzsetparams (file, level, strategy) - gzFile file; - int level; - int strategy; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - /* Make room to allow flushing */ - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - } - s->stream.avail_out = Z_BUFSIZE; - } - - return deflateParams (&(s->stream), level, strategy); -} - -/* =========================================================================== - Read a byte from a gz_stream; update next_in and avail_in. Return EOF - for end of file. - IN assertion: the stream s has been sucessfully opened for reading. -*/ -local int get_byte(s) - gz_stream *s; -{ - if (s->z_eof) return EOF; - if (s->stream.avail_in == 0) { - errno = 0; - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) s->z_err = Z_ERRNO; - return EOF; - } - s->stream.next_in = s->inbuf; - } - s->stream.avail_in--; - return *(s->stream.next_in)++; -} - -/* =========================================================================== - Check the gzip header of a gz_stream opened for reading. Set the stream - mode to transparent if the gzip magic header is not present; set s->err - to Z_DATA_ERROR if the magic header is present but the rest of the header - is incorrect. - IN assertion: the stream s has already been created sucessfully; - s->stream.avail_in is zero for the first time, but may be non-zero - for concatenated .gz files. -*/ -local void check_header(s) - gz_stream *s; -{ - int method; /* method byte */ - int flags; /* flags byte */ - uInt len; - int c; - - /* Assure two bytes in the buffer so we can peek ahead -- handle case - where first byte of header is at the end of the buffer after the last - gzip segment */ - len = s->stream.avail_in; - if (len < 2) { - if (len) s->inbuf[0] = s->stream.next_in[0]; - errno = 0; - len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file); - if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; - s->stream.avail_in += len; - s->stream.next_in = s->inbuf; - if (s->stream.avail_in < 2) { - s->transparent = s->stream.avail_in; - return; - } - } - - /* Peek ahead to check the gzip magic header */ - if (s->stream.next_in[0] != gz_magic[0] || - s->stream.next_in[1] != gz_magic[1]) { - s->transparent = 1; - return; - } - s->stream.avail_in -= 2; - s->stream.next_in += 2; - - /* Check the rest of the gzip header */ - method = get_byte(s); - flags = get_byte(s); - if (method != Z_DEFLATED || (flags & RESERVED) != 0) { - s->z_err = Z_DATA_ERROR; - return; - } - - /* Discard time, xflags and OS code: */ - for (len = 0; len < 6; len++) (void)get_byte(s); - - if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ - len = (uInt)get_byte(s); - len += ((uInt)get_byte(s))<<8; - /* len is garbage if EOF but the loop below will quit anyway */ - while (len-- != 0 && get_byte(s) != EOF) ; - } - if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ - for (len = 0; len < 2; len++) (void)get_byte(s); - } - s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; -} - - /* =========================================================================== - * Cleanup then free the given gz_stream. Return a zlib error code. - Try freeing in the reverse order of allocations. - */ -local int destroy (s) - gz_stream *s; -{ - int err = Z_OK; - - if (!s) return Z_STREAM_ERROR; - - TRYFREE(s->msg); - - if (s->stream.state != NULL) { - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - err = Z_STREAM_ERROR; -#else - err = deflateEnd(&(s->stream)); -#endif - } else if (s->mode == 'r') { - err = inflateEnd(&(s->stream)); - } - } - if (s->file != NULL && fclose(s->file)) { -#ifdef ESPIPE - if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ -#endif - err = Z_ERRNO; - } - if (s->z_err < 0) err = s->z_err; - - TRYFREE(s->inbuf); - TRYFREE(s->outbuf); - TRYFREE(s->path); - TRYFREE(s); - return err; -} - -/* =========================================================================== - Reads the given number of uncompressed bytes from the compressed file. - gzread returns the number of bytes actually read (0 for end of file). -*/ -int ZEXPORT gzread (file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ - gz_stream *s = (gz_stream*)file; - Bytef *start = (Bytef*)buf; /* starting point for crc computation */ - Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ - - if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; - - if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; - if (s->z_err == Z_STREAM_END) return 0; /* EOF */ - - next_out = (Byte*)buf; - s->stream.next_out = (Bytef*)buf; - s->stream.avail_out = len; - - if (s->stream.avail_out && s->back != EOF) { - *next_out++ = s->back; - s->stream.next_out++; - s->stream.avail_out--; - s->back = EOF; - s->out++; - start++; - if (s->last) { - s->z_err = Z_STREAM_END; - return 1; - } - } - - while (s->stream.avail_out != 0) { - - if (s->transparent) { - /* Copy first the lookahead bytes: */ - uInt n = s->stream.avail_in; - if (n > s->stream.avail_out) n = s->stream.avail_out; - if (n > 0) { - zmemcpy(s->stream.next_out, s->stream.next_in, n); - next_out += n; - s->stream.next_out = next_out; - s->stream.next_in += n; - s->stream.avail_out -= n; - s->stream.avail_in -= n; - } - if (s->stream.avail_out > 0) { - s->stream.avail_out -= - (uInt)fread(next_out, 1, s->stream.avail_out, s->file); - } - len -= s->stream.avail_out; - s->in += len; - s->out += len; - if (len == 0) s->z_eof = 1; - return (int)len; - } - if (s->stream.avail_in == 0 && !s->z_eof) { - - errno = 0; - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) { - s->z_err = Z_ERRNO; - break; - } - } - s->stream.next_in = s->inbuf; - } - s->in += s->stream.avail_in; - s->out += s->stream.avail_out; - s->z_err = inflate(&(s->stream), Z_NO_FLUSH); - s->in -= s->stream.avail_in; - s->out -= s->stream.avail_out; - - if (s->z_err == Z_STREAM_END) { - /* Check CRC and original size */ - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - start = s->stream.next_out; - - if (getLong(s) != s->crc) { - s->z_err = Z_DATA_ERROR; - } else { - (void)getLong(s); - /* The uncompressed length returned by above getlong() may be - * different from s->out in case of concatenated .gz files. - * Check for such files: - */ - check_header(s); - if (s->z_err == Z_OK) { - inflateReset(&(s->stream)); - s->crc = crc32(0L, Z_NULL, 0); - } - } - } - if (s->z_err != Z_OK || s->z_eof) break; - } - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - - if (len == s->stream.avail_out && - (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)) - return -1; - return (int)(len - s->stream.avail_out); -} - - -/* =========================================================================== - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ -int ZEXPORT gzgetc(file) - gzFile file; -{ - unsigned char c; - - return gzread(file, &c, 1) == 1 ? c : -1; -} - - -/* =========================================================================== - Push one byte back onto the stream. -*/ -int ZEXPORT gzungetc(c, file) - int c; - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF; - s->back = c; - s->out--; - s->last = (s->z_err == Z_STREAM_END); - if (s->last) s->z_err = Z_OK; - s->z_eof = 0; - return c; -} - - -/* =========================================================================== - Reads bytes from the compressed file until len-1 characters are - read, or a newline character is read and transferred to buf, or an - end-of-file condition is encountered. The string is then terminated - with a null character. - gzgets returns buf, or Z_NULL in case of error. - - The current implementation is not optimized at all. -*/ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ - char *b = buf; - if (buf == Z_NULL || len <= 0) return Z_NULL; - - while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ; - *buf = '\0'; - return b == buf && len > 0 ? Z_NULL : b; -} - - -#ifndef NO_GZCOMPRESS -/* =========================================================================== - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of bytes actually written (0 in case of error). -*/ -int ZEXPORT gzwrite (file, buf, len) - gzFile file; - voidpc buf; - unsigned len; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.next_in = (Bytef*)buf; - s->stream.avail_in = len; - - while (s->stream.avail_in != 0) { - - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - break; - } - s->stream.avail_out = Z_BUFSIZE; - } - s->in += s->stream.avail_in; - s->out += s->stream.avail_out; - s->z_err = deflate(&(s->stream), Z_NO_FLUSH); - s->in -= s->stream.avail_in; - s->out -= s->stream.avail_out; - if (s->z_err != Z_OK) break; - } - s->crc = crc32(s->crc, (const Bytef *)buf, len); - - return (int)(len - s->stream.avail_in); -} - - -/* =========================================================================== - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). -*/ -#ifdef STDC -#include - -int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) -{ - char buf[Z_PRINTF_BUFSIZE]; - va_list va; - int len; - - buf[sizeof(buf) - 1] = 0; - va_start(va, format); -#ifdef NO_vsnprintf -# ifdef HAS_vsprintf_void - (void)vsprintf(buf, format, va); - va_end(va); - for (len = 0; len < sizeof(buf); len++) - if (buf[len] == 0) break; -# else - len = vsprintf(buf, format, va); - va_end(va); -# endif -#else -# ifdef HAS_vsnprintf_void - (void)vsnprintf(buf, sizeof(buf), format, va); - va_end(va); - len = strlen(buf); -# else - len = vsnprintf(buf, sizeof(buf), format, va); - va_end(va); -# endif -#endif - if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0) - return 0; - return gzwrite(file, buf, (unsigned)len); -} -#else /* not ANSI C */ - -int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ - char buf[Z_PRINTF_BUFSIZE]; - int len; - - buf[sizeof(buf) - 1] = 0; -#ifdef NO_snprintf -# ifdef HAS_sprintf_void - sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - for (len = 0; len < sizeof(buf); len++) - if (buf[len] == 0) break; -# else - len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#else -# ifdef HAS_snprintf_void - snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - len = strlen(buf); -# else - len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#endif - if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0) - return 0; - return gzwrite(file, buf, len); -} -#endif - -/* =========================================================================== - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ - unsigned char cc = (unsigned char) c; /* required for big endian systems */ - - return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; -} - - -/* =========================================================================== - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ -int ZEXPORT gzputs(file, s) - gzFile file; - const char *s; -{ - return gzwrite(file, (char*)s, (unsigned)strlen(s)); -} - - -/* =========================================================================== - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. -*/ -local int do_flush (file, flush) - gzFile file; - int flush; -{ - uInt len; - int done = 0; - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.avail_in = 0; /* should be zero already anyway */ - - for (;;) { - len = Z_BUFSIZE - s->stream.avail_out; - - if (len != 0) { - if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { - s->z_err = Z_ERRNO; - return Z_ERRNO; - } - s->stream.next_out = s->outbuf; - s->stream.avail_out = Z_BUFSIZE; - } - if (done) break; - s->out += s->stream.avail_out; - s->z_err = deflate(&(s->stream), flush); - s->out -= s->stream.avail_out; - - /* Ignore the second of two consecutive flushes: */ - if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; - - /* deflate has finished flushing only when it hasn't used up - * all the available space in the output buffer: - */ - done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); - - if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; - } - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} - -int ZEXPORT gzflush (file, flush) - gzFile file; - int flush; -{ - gz_stream *s = (gz_stream*)file; - int err = do_flush (file, flush); - - if (err) return err; - fflush(s->file); - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} -#endif /* NO_GZCOMPRESS */ - -/* =========================================================================== - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error. - SEEK_END is not implemented, returns error. - In this version of the library, gzseek can be extremely slow. -*/ -z_off_t ZEXPORT gzseek (file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || whence == SEEK_END || - s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { - return -1L; - } - - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - return -1L; -#else - if (whence == SEEK_SET) { - offset -= s->in; - } - if (offset < 0) return -1L; - - /* At this point, offset is the number of zero bytes to write. */ - if (s->inbuf == Z_NULL) { - s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ - if (s->inbuf == Z_NULL) return -1L; - zmemzero(s->inbuf, Z_BUFSIZE); - } - while (offset > 0) { - uInt size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (uInt)offset; - - size = gzwrite(file, s->inbuf, size); - if (size == 0) return -1L; - - offset -= size; - } - return s->in; -#endif - } - /* Rest of function is for reading only */ - - /* compute absolute position */ - if (whence == SEEK_CUR) { - offset += s->out; - } - if (offset < 0) return -1L; - - if (s->transparent) { - /* map to fseek */ - s->back = EOF; - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; - - s->in = s->out = offset; - return offset; - } - - /* For a negative seek, rewind and use positive seek */ - if (offset >= s->out) { - offset -= s->out; - } else if (gzrewind(file) < 0) { - return -1L; - } - /* offset is now the number of bytes to skip. */ - - if (offset != 0 && s->outbuf == Z_NULL) { - s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); - if (s->outbuf == Z_NULL) return -1L; - } - if (offset && s->back != EOF) { - s->back = EOF; - s->out++; - offset--; - if (s->last) s->z_err = Z_STREAM_END; - } - while (offset > 0) { - int size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (int)offset; - - size = gzread(file, s->outbuf, (uInt)size); - if (size <= 0) return -1L; - offset -= size; - } - return s->out; -} - -/* =========================================================================== - Rewinds input file. -*/ -int ZEXPORT gzrewind (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r') return -1; - - s->z_err = Z_OK; - s->z_eof = 0; - s->back = EOF; - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - s->crc = crc32(0L, Z_NULL, 0); - if (!s->transparent) (void)inflateReset(&s->stream); - s->in = 0; - s->out = 0; - return fseek(s->file, s->start, SEEK_SET); -} - -/* =========================================================================== - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. -*/ -z_off_t ZEXPORT gztell (file) - gzFile file; -{ - return gzseek(file, 0L, SEEK_CUR); -} - -/* =========================================================================== - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ -int ZEXPORT gzeof (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - /* With concatenated compressed files that can have embedded - * crc trailers, z_eof is no longer the only/best indicator of EOF - * on a gz_stream. Handle end-of-stream error explicitly here. - */ - if (s == NULL || s->mode != 'r') return 0; - if (s->z_eof) return 1; - return s->z_err == Z_STREAM_END; -} - -/* =========================================================================== - Returns 1 if reading and doing so transparently, otherwise zero. -*/ -int ZEXPORT gzdirect (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r') return 0; - return s->transparent; -} - -/* =========================================================================== - Outputs a long in LSB order to the given file -*/ -local void putLong (file, x) - FILE *file; - uLong x; -{ - int n; - for (n = 0; n < 4; n++) { - fputc((int)(x & 0xff), file); - x >>= 8; - } -} - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets z_err in case - of error. -*/ -local uLong getLong (s) - gz_stream *s; -{ - uLong x = (uLong)get_byte(s); - int c; - - x += ((uLong)get_byte(s))<<8; - x += ((uLong)get_byte(s))<<16; - c = get_byte(s); - if (c == EOF) s->z_err = Z_DATA_ERROR; - x += ((uLong)c)<<24; - return x; -} - -/* =========================================================================== - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. -*/ -int ZEXPORT gzclose (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL) return Z_STREAM_ERROR; - - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - return Z_STREAM_ERROR; -#else - if (do_flush (file, Z_FINISH) != Z_OK) - return destroy((gz_stream*)file); - - putLong (s->file, s->crc); - putLong (s->file, (uLong)(s->in & 0xffffffff)); -#endif - } - return destroy((gz_stream*)file); -} - -#ifdef STDC -# define zstrerror(errnum) strerror(errnum) -#else -# define zstrerror(errnum) "" -#endif - -/* =========================================================================== - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ -const char * ZEXPORT gzerror (file, errnum) - gzFile file; - int *errnum; -{ - char *m; - gz_stream *s = (gz_stream*)file; - - if (s == NULL) { - *errnum = Z_STREAM_ERROR; - return (const char*)ERR_MSG(Z_STREAM_ERROR); - } - *errnum = s->z_err; - if (*errnum == Z_OK) return (const char*)""; - - m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); - - if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); - - TRYFREE(s->msg); - s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); - if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR); - strcpy(s->msg, s->path); - strcat(s->msg, ": "); - strcat(s->msg, m); - return (const char*)s->msg; -} - -/* =========================================================================== - Clear the error and end-of-file flags, and do the same for the real file. -*/ -void ZEXPORT gzclearerr (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL) return; - if (s->z_err != Z_STREAM_END) s->z_err = Z_OK; - s->z_eof = 0; - clearerr(s->file); -} diff --git a/sourcepawn/compiler/zlib/infback.c b/sourcepawn/compiler/zlib/infback.c deleted file mode 100644 index 0056928e..00000000 --- a/sourcepawn/compiler/zlib/infback.c +++ /dev/null @@ -1,624 +0,0 @@ -/* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - This code is largely copied from inflate.c. Normally either infback.o or - inflate.o would be linked into an application--not both. The interface - with inffast.c is retained so that optimized assembler-coded versions of - inflate_fast() can be used with either inflate.c or infback.c. - */ - -#include -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - -/* - strm provides memory allocation functions in zalloc and zfree, or - Z_NULL to use the library memory allocation functions. - - windowBits is in the range 8..15, and window is a user-supplied - window and output buffer that is 2**windowBits bytes. - */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL || window == Z_NULL || - windowBits < 8 || windowBits > 15) - return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state FAR *)ZALLOC(strm, 1, - sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->dmax = 32768U; - state->wbits = windowBits; - state->wsize = 1U << windowBits; - state->window = window; - state->write = 0; - state->whave = 0; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -/* Macros for inflateBack(): */ - -/* Load returned state from inflate_fast() */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Set state from registers for inflate_fast() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Assure that some input is available. If input is requested, but denied, - then return a Z_BUF_ERROR from inflateBack(). */ -#define PULL() \ - do { \ - if (have == 0) { \ - have = in(in_desc, &next); \ - if (have == 0) { \ - next = Z_NULL; \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflateBack() - with an error if there is no input available. */ -#define PULLBYTE() \ - do { \ - PULL(); \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflateBack() with - an error. */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Assure that some output space is available, by writing out the window - if it's full. If the write fails, return from inflateBack() with a - Z_BUF_ERROR. */ -#define ROOM() \ - do { \ - if (left == 0) { \ - put = state->window; \ - left = state->wsize; \ - state->whave = left; \ - if (out(out_desc, put, left)) { \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* - strm provides the memory allocation functions and window buffer on input, - and provides information on the unused input on return. For Z_DATA_ERROR - returns, strm will also provide an error message. - - in() and out() are the call-back input and output functions. When - inflateBack() needs more input, it calls in(). When inflateBack() has - filled the window with output, or when it completes with data in the - window, it calls out() to write out the data. The application must not - change the provided input until in() is called again or inflateBack() - returns. The application must not change the window/output buffer until - inflateBack() returns. - - in() and out() are called with a descriptor parameter provided in the - inflateBack() call. This parameter can be a structure that provides the - information required to do the read or write, as well as accumulated - information on the input and output such as totals and check values. - - in() should return zero on failure. out() should return non-zero on - failure. If either in() or out() fails, than inflateBack() returns a - Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it - was in() or out() that caused in the error. Otherwise, inflateBack() - returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format - error, or Z_MEM_ERROR if it could not allocate memory for the state. - inflateBack() can also return Z_STREAM_ERROR if the input parameters - are not correct, i.e. strm is Z_NULL or the state was not initialized. - */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ - struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code this; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - /* Check that the strm exists and that the state was initialized */ - if (strm == Z_NULL || strm->state == Z_NULL) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* Reset the state */ - strm->msg = Z_NULL; - state->mode = TYPE; - state->last = 0; - state->whave = 0; - next = strm->next_in; - have = next != Z_NULL ? strm->avail_in : 0; - hold = 0; - bits = 0; - put = state->window; - left = state->wsize; - - /* Inflate until end of block marked as last */ - for (;;) - switch (state->mode) { - case TYPE: - /* determine and dispatch block type */ - if (state->last) { - BYTEBITS(); - state->mode = DONE; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - - case STORED: - /* get and verify stored block length */ - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - - /* copy stored block from input to output */ - while (state->length != 0) { - copy = state->length; - PULL(); - ROOM(); - if (copy > have) copy = have; - if (copy > left) copy = left; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - - case TABLE: - /* get dynamic table entries descriptor */ - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - - /* get code length code lengths (not a typo) */ - state->have = 0; - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - - /* get length and distance code code lengths */ - state->have = 0; - while (state->have < state->nlen + state->ndist) { - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.val < 16) { - NEEDBITS(this.bits); - DROPBITS(this.bits); - state->lens[state->have++] = this.val; - } - else { - if (this.val == 16) { - NEEDBITS(this.bits + 2); - DROPBITS(this.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = (unsigned)(state->lens[state->have - 1]); - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (this.val == 17) { - NEEDBITS(this.bits + 3); - DROPBITS(this.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(this.bits + 7); - DROPBITS(this.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* build code tables */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - - case LEN: - /* use inflate_fast() if we have enough input and output */ - if (have >= 6 && left >= 258) { - RESTORE(); - if (state->whave < state->wsize) - state->whave = state->wsize - left; - inflate_fast(strm, state->wsize); - LOAD(); - break; - } - - /* get a literal, length, or end-of-block code */ - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.op && (this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - state->length = (unsigned)this.val; - - /* process literal */ - if (this.op == 0) { - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - ROOM(); - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - } - - /* process end of block */ - if (this.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - - /* invalid code */ - if (this.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - - /* length code -- get extra bits, if any */ - state->extra = (unsigned)(this.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - - /* get distance code */ - for (;;) { - this = state->distcode[BITS(state->distbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if ((this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - if (this.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)this.val; - - /* get distance extra bits, if any */ - state->extra = (unsigned)(this.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } - if (state->offset > state->wsize - (state->whave < state->wsize ? - left : 0)) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - - /* copy match from window to output */ - do { - ROOM(); - copy = state->wsize - state->offset; - if (copy < left) { - from = put + copy; - copy = left - copy; - } - else { - from = put - state->offset; - copy = left; - } - if (copy > state->length) copy = state->length; - state->length -= copy; - left -= copy; - do { - *put++ = *from++; - } while (--copy); - } while (state->length != 0); - break; - - case DONE: - /* inflate stream terminated properly -- write leftover output */ - ret = Z_STREAM_END; - if (left < state->wsize) { - if (out(out_desc, state->window, state->wsize - left)) - ret = Z_BUF_ERROR; - } - goto inf_leave; - - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - - default: /* can't happen, but makes compilers happy */ - ret = Z_STREAM_ERROR; - goto inf_leave; - } - - /* Return unused input */ - inf_leave: - strm->next_in = next; - strm->avail_in = have; - return ret; -} - -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} diff --git a/sourcepawn/compiler/zlib/inffast.c b/sourcepawn/compiler/zlib/inffast.c deleted file mode 100644 index 20ef523d..00000000 --- a/sourcepawn/compiler/zlib/inffast.c +++ /dev/null @@ -1,319 +0,0 @@ -/* inffast.c -- fast decoding - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifndef ASMINF - -/* Allow machine dependent optimization for post-increment or pre-increment. - Based on testing to date, - Pre-increment preferred for: - - PowerPC G3 (Adler) - - MIPS R5000 (Randers-Pehrson) - Post-increment preferred for: - - none - No measurable difference: - - Pentium III (Anderson) - - M68060 (Nikl) - */ -#ifdef POSTINC -# define OFF 0 -# define PUP(a) *(a)++ -#else -# define OFF 1 -# define PUP(a) *++(a) -#endif - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state->mode == LEN - strm->avail_in >= 6 - strm->avail_out >= 258 - start >= strm->avail_out - state->bits < 8 - - On return, state->mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm->avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for - output space. - */ -void inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ - struct inflate_state FAR *state; - unsigned char FAR *in; /* local strm->next_in */ - unsigned char FAR *last; /* while in < last, enough input available */ - unsigned char FAR *out; /* local strm->next_out */ - unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ - unsigned char FAR *end; /* while out < end, enough space available */ -#ifdef INFLATE_STRICT - unsigned dmax; /* maximum distance from zlib header */ -#endif - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned write; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ - unsigned long hold; /* local strm->hold */ - unsigned bits; /* local strm->bits */ - code const FAR *lcode; /* local strm->lencode */ - code const FAR *dcode; /* local strm->distcode */ - unsigned lmask; /* mask for first level of length codes */ - unsigned dmask; /* mask for first level of distance codes */ - code this; /* retrieved table entry */ - unsigned op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - unsigned len; /* match length, unused bytes */ - unsigned dist; /* match distance */ - unsigned char FAR *from; /* where to copy match from */ - - /* copy state to local variables */ - state = (struct inflate_state FAR *)strm->state; - in = strm->next_in - OFF; - last = in + (strm->avail_in - 5); - out = strm->next_out - OFF; - beg = out - (start - strm->avail_out); - end = out + (strm->avail_out - 257); -#ifdef INFLATE_STRICT - dmax = state->dmax; -#endif - wsize = state->wsize; - whave = state->whave; - write = state->write; - window = state->window; - hold = state->hold; - bits = state->bits; - lcode = state->lencode; - dcode = state->distcode; - lmask = (1U << state->lenbits) - 1; - dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - do { - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - this = lcode[hold & lmask]; - dolen: - op = (unsigned)(this.bits); - hold >>= op; - bits -= op; - op = (unsigned)(this.op); - if (op == 0) { /* literal */ - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - PUP(out) = (unsigned char)(this.val); - } - else if (op & 16) { /* length base */ - len = (unsigned)(this.val); - op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - len += (unsigned)hold & ((1U << op) - 1); - hold >>= op; - bits -= op; - } - Tracevv((stderr, "inflate: length %u\n", len)); - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - this = dcode[hold & dmask]; - dodist: - op = (unsigned)(this.bits); - hold >>= op; - bits -= op; - op = (unsigned)(this.op); - if (op & 16) { /* distance base */ - dist = (unsigned)(this.val); - op &= 15; /* number of extra bits */ - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - } - dist += (unsigned)hold & ((1U << op) - 1); -#ifdef INFLATE_STRICT - if (dist > dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - hold >>= op; - bits -= op; - Tracevv((stderr, "inflate: distance %u\n", dist)); - op = (unsigned)(out - beg); /* max distance in output */ - if (dist > op) { /* see if copy from window */ - op = dist - op; /* distance back in window */ - if (op > whave) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - from = window - OFF; - if (write == 0) { /* very common case */ - from += wsize - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - else if (write < op) { /* wrap around window */ - from += wsize + write - op; - op -= write; - if (op < len) { /* some from end of window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = window - OFF; - if (write < len) { /* some from start of window */ - op = write; - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - } - else { /* contiguous in window */ - from += write - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - while (len > 2) { - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - else { - from = out - dist; /* copy direct from output */ - do { /* minimum length is three */ - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } while (len > 2); - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - } - else if ((op & 64) == 0) { /* 2nd level distance code */ - this = dcode[this.val + (hold & ((1U << op) - 1))]; - goto dodist; - } - else { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - } - else if ((op & 64) == 0) { /* 2nd level length code */ - this = lcode[this.val + (hold & ((1U << op) - 1))]; - goto dolen; - } - else if (op & 32) { /* end-of-block */ - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - else { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - } while (in < last && out < end); - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - len = bits >> 3; - in -= len; - bits -= len << 3; - hold &= (1U << bits) - 1; - - /* update state and return */ - strm->next_in = in + OFF; - strm->next_out = out + OFF; - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); - strm->avail_out = (unsigned)(out < end ? - 257 + (end - out) : 257 - (out - end)); - state->hold = hold; - state->bits = bits; - return; -} - -/* - inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): - - Using bit fields for code structure - - Different op definition to avoid & for extra bits (do & for table bits) - - Three separate decoding do-loops for direct, window, and write == 0 - - Special case for distance > 1 copies to do overlapped load and store copy - - Explicit branch predictions (based on measured branch probabilities) - - Deferring match copy and interspersed it with decoding subsequent codes - - Swapping literal/length else - - Swapping window/direct else - - Larger unrolled copy loops (three is about right) - - Moving len -= 3 statement into middle of loop - */ - -#endif /* !ASMINF */ diff --git a/sourcepawn/compiler/zlib/inffast.h b/sourcepawn/compiler/zlib/inffast.h deleted file mode 100644 index 614fa787..00000000 --- a/sourcepawn/compiler/zlib/inffast.h +++ /dev/null @@ -1,11 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2003 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -void inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/sourcepawn/compiler/zlib/inffixed.h b/sourcepawn/compiler/zlib/inffixed.h deleted file mode 100644 index 423d5c5b..00000000 --- a/sourcepawn/compiler/zlib/inffixed.h +++ /dev/null @@ -1,94 +0,0 @@ - /* inffixed.h -- table for decoding fixed codes - * Generated automatically by makefixed(). - */ - - /* WARNING: this file should *not* be used by applications. It - is part of the implementation of the compression library and - is subject to change. Applications should only use zlib.h. - */ - - static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} - }; - - static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} - }; diff --git a/sourcepawn/compiler/zlib/inflate.c b/sourcepawn/compiler/zlib/inflate.c deleted file mode 100644 index f4606b62..00000000 --- a/sourcepawn/compiler/zlib/inflate.c +++ /dev/null @@ -1,1369 +0,0 @@ -/* inflate.c -- zlib decompression - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * Change history: - * - * 1.2.beta0 24 Nov 2002 - * - First version -- complete rewrite of inflate to simplify code, avoid - * creation of window when not needed, minimize use of window when it is - * needed, make inffast.c even faster, implement gzip decoding, and to - * improve code readability and style over the previous zlib inflate code - * - * 1.2.beta1 25 Nov 2002 - * - Use pointers for available input and output checking in inffast.c - * - Remove input and output counters in inffast.c - * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 - * - Remove unnecessary second byte pull from length extra in inffast.c - * - Unroll direct copy to three copies per loop in inffast.c - * - * 1.2.beta2 4 Dec 2002 - * - Change external routine names to reduce potential conflicts - * - Correct filename to inffixed.h for fixed tables in inflate.c - * - Make hbuf[] unsigned char to match parameter type in inflate.c - * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) - * to avoid negation problem on Alphas (64 bit) in inflate.c - * - * 1.2.beta3 22 Dec 2002 - * - Add comments on state->bits assertion in inffast.c - * - Add comments on op field in inftrees.h - * - Fix bug in reuse of allocated window after inflateReset() - * - Remove bit fields--back to byte structure for speed - * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths - * - Change post-increments to pre-increments in inflate_fast(), PPC biased? - * - Add compile time option, POSTINC, to use post-increments instead (Intel?) - * - Make MATCH copy in inflate() much faster for when inflate_fast() not used - * - Use local copies of stream next and avail values, as well as local bit - * buffer and bit count in inflate()--for speed when inflate_fast() not used - * - * 1.2.beta4 1 Jan 2003 - * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings - * - Move a comment on output buffer sizes from inffast.c to inflate.c - * - Add comments in inffast.c to introduce the inflate_fast() routine - * - Rearrange window copies in inflate_fast() for speed and simplification - * - Unroll last copy for window match in inflate_fast() - * - Use local copies of window variables in inflate_fast() for speed - * - Pull out common write == 0 case for speed in inflate_fast() - * - Make op and len in inflate_fast() unsigned for consistency - * - Add FAR to lcode and dcode declarations in inflate_fast() - * - Simplified bad distance check in inflate_fast() - * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new - * source file infback.c to provide a call-back interface to inflate for - * programs like gzip and unzip -- uses window as output buffer to avoid - * window copying - * - * 1.2.beta5 1 Jan 2003 - * - Improved inflateBack() interface to allow the caller to provide initial - * input in strm. - * - Fixed stored blocks bug in inflateBack() - * - * 1.2.beta6 4 Jan 2003 - * - Added comments in inffast.c on effectiveness of POSTINC - * - Typecasting all around to reduce compiler warnings - * - Changed loops from while (1) or do {} while (1) to for (;;), again to - * make compilers happy - * - Changed type of window in inflateBackInit() to unsigned char * - * - * 1.2.beta7 27 Jan 2003 - * - Changed many types to unsigned or unsigned short to avoid warnings - * - Added inflateCopy() function - * - * 1.2.0 9 Mar 2003 - * - Changed inflateBack() interface to provide separate opaque descriptors - * for the in() and out() functions - * - Changed inflateBack() argument and in_func typedef to swap the length - * and buffer address return values for the input function - * - Check next_in and next_out for Z_NULL on entry to inflate() - * - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. - */ - -#include -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifdef MAKEFIXED -# ifndef BUILDFIXED -# define BUILDFIXED -# endif -#endif - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, unsigned out)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, - unsigned len)); - -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - strm->total_in = strm->total_out = state->total = 0; - strm->msg = Z_NULL; - strm->adler = 1; /* to support ill-conceived Java test suite */ - state->mode = HEAD; - state->last = 0; - state->havedict = 0; - state->dmax = 32768U; - state->head = Z_NULL; - state->wsize = 0; - state->whave = 0; - state->write = 0; - state->hold = 0; - state->bits = 0; - state->lencode = state->distcode = state->next = state->codes; - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; - value &= (1L << bits) - 1; - state->hold += value << state->bits; - state->bits += bits; - return Z_OK; -} - -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL) return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state FAR *) - ZALLOC(strm, 1, sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - if (windowBits < 0) { - state->wrap = 0; - windowBits = -windowBits; - } - else { - state->wrap = (windowBits >> 4) + 1; -#ifdef GUNZIP - if (windowBits < 48) windowBits &= 15; -#endif - } - if (windowBits < 8 || windowBits > 15) { - ZFREE(strm, state); - strm->state = Z_NULL; - return Z_STREAM_ERROR; - } - state->wbits = (unsigned)windowBits; - state->window = Z_NULL; - return inflateReset(strm); -} - -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ - return inflateInit2_(strm, DEF_WBITS, version, stream_size); -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -#ifdef MAKEFIXED -#include - -/* - Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also - defines BUILDFIXED, so the tables are built on the fly. makefixed() writes - those tables to stdout, which would be piped to inffixed.h. A small program - can simply call makefixed to do this: - - void makefixed(void); - - int main(void) - { - makefixed(); - return 0; - } - - Then that can be linked with zlib built with MAKEFIXED defined and run: - - a.out > inffixed.h - */ -void makefixed() -{ - unsigned low, size; - struct inflate_state state; - - fixedtables(&state); - puts(" /* inffixed.h -- table for decoding fixed codes"); - puts(" * Generated automatically by makefixed()."); - puts(" */"); - puts(""); - puts(" /* WARNING: this file should *not* be used by applications."); - puts(" It is part of the implementation of this library and is"); - puts(" subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - size = 1U << 9; - printf(" static const code lenfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 7) == 0) printf("\n "); - printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, - state.lencode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); - size = 1U << 5; - printf("\n static const code distfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 6) == 0) printf("\n "); - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, - state.distcode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); -} -#endif /* MAKEFIXED */ - -/* - Update the window with the last wsize (normally 32K) bytes written before - returning. If window does not exist yet, create it. This is only called - when a window is already in use, or when output has been written during this - inflate call, but the end of the deflate stream has not been reached yet. - It is also called to create a window for dictionary data when a dictionary - is loaded. - - Providing output buffers larger than 32K to inflate() should provide a speed - advantage, since only the last 32K of output is copied to the sliding window - upon return from inflate(), and since all distances after the first 32K of - output will fall in the output data, making match copies simpler and faster. - The advantage may be dependent on the size of the processor's data caches. - */ -local int updatewindow(strm, out) -z_streamp strm; -unsigned out; -{ - struct inflate_state FAR *state; - unsigned copy, dist; - - state = (struct inflate_state FAR *)strm->state; - - /* if it hasn't been done already, allocate space for the window */ - if (state->window == Z_NULL) { - state->window = (unsigned char FAR *) - ZALLOC(strm, 1U << state->wbits, - sizeof(unsigned char)); - if (state->window == Z_NULL) return 1; - } - - /* if window not in use yet, initialize */ - if (state->wsize == 0) { - state->wsize = 1U << state->wbits; - state->write = 0; - state->whave = 0; - } - - /* copy state->wsize or less output bytes into the circular window */ - copy = out - strm->avail_out; - if (copy >= state->wsize) { - zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); - state->write = 0; - state->whave = state->wsize; - } - else { - dist = state->wsize - state->write; - if (dist > copy) dist = copy; - zmemcpy(state->window + state->write, strm->next_out - copy, dist); - copy -= dist; - if (copy) { - zmemcpy(state->window, strm->next_out - copy, copy); - state->write = copy; - state->whave = state->wsize; - } - else { - state->write += dist; - if (state->write == state->wsize) state->write = 0; - if (state->whave < state->wsize) state->whave += dist; - } - } - return 0; -} - -/* Macros for inflate(): */ - -/* check function to use adler32() for zlib or crc32() for gzip */ -#ifdef GUNZIP -# define UPDATE(check, buf, len) \ - (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) -#else -# define UPDATE(check, buf, len) adler32(check, buf, len) -#endif - -/* check macros for header crc */ -#ifdef GUNZIP -# define CRC2(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - check = crc32(check, hbuf, 2); \ - } while (0) - -# define CRC4(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - hbuf[2] = (unsigned char)((word) >> 16); \ - hbuf[3] = (unsigned char)((word) >> 24); \ - check = crc32(check, hbuf, 4); \ - } while (0) -#endif - -/* Load registers with state in inflate() for speed */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Restore state from registers in inflate() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflate() - if there is no input available. */ -#define PULLBYTE() \ - do { \ - if (have == 0) goto inf_leave; \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflate(). */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Reverse the bytes in a 32-bit value */ -#define REVERSE(q) \ - ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - -/* - inflate() uses a state machine to process as much input data and generate as - much output data as possible before returning. The state machine is - structured roughly as follows: - - for (;;) switch (state) { - ... - case STATEn: - if (not enough input data or output space to make progress) - return; - ... make progress ... - state = STATEm; - break; - ... - } - - so when inflate() is called again, the same case is attempted again, and - if the appropriate resources are provided, the machine proceeds to the - next state. The NEEDBITS() macro is usually the way the state evaluates - whether it can proceed or should return. NEEDBITS() does the return if - the requested bits are not available. The typical use of the BITS macros - is: - - NEEDBITS(n); - ... do something with BITS(n) ... - DROPBITS(n); - - where NEEDBITS(n) either returns from inflate() if there isn't enough - input left to load n bits into the accumulator, or it continues. BITS(n) - gives the low n bits in the accumulator. When done, DROPBITS(n) drops - the low n bits off the accumulator. INITBITS() clears the accumulator - and sets the number of available bits to zero. BYTEBITS() discards just - enough bits to put the accumulator on a byte boundary. After BYTEBITS() - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. - - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return - if there is no input available. The decoding of variable length codes uses - PULLBYTE() directly in order to pull just enough bytes to decode the next - code, and no more. - - Some states loop until they get enough input, making sure that enough - state information is maintained to continue the loop where it left off - if NEEDBITS() returns in the loop. For example, want, need, and keep - would all have to actually be part of the saved state in case NEEDBITS() - returns: - - case STATEw: - while (want < need) { - NEEDBITS(n); - keep[want++] = BITS(n); - DROPBITS(n); - } - state = STATEx; - case STATEx: - - As shown above, if the next state is also the next case, then the break - is omitted. - - A state may also return if there is not enough output space available to - complete that state. Those states are copying stored data, writing a - literal byte, and copying a matching string. - - When returning, a "goto inf_leave" is used to update the total counters, - update the check value, and determine whether any progress has been made - during that inflate() call in order to return the proper return code. - Progress is defined as a change in either strm->avail_in or strm->avail_out. - When there is a window, goto inf_leave will update the window with the last - output written. If a goto inf_leave occurs in the middle of decompression - and there is no window currently, goto inf_leave will create one and copy - output to the window for the next call of inflate(). - - In this implementation, the flush parameter of inflate() only affects the - return code (per zlib.h). inflate() always writes as much as possible to - strm->next_out, given the space available and the provided input--the effect - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers - the allocation of and copying into a sliding window until necessary, which - provides the effect documented in zlib.h for Z_FINISH when the entire input - stream available. So the only thing the flush parameter actually does is: - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it - will return Z_BUF_ERROR if it has not reached the end of the stream. - */ - -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ - struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned in, out; /* save starting available input and output */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code this; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ -#ifdef GUNZIP - unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ -#endif - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0)) - return Z_STREAM_ERROR; - - state = (struct inflate_state FAR *)strm->state; - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ - LOAD(); - in = have; - out = left; - ret = Z_OK; - for (;;) - switch (state->mode) { - case HEAD: - if (state->wrap == 0) { - state->mode = TYPEDO; - break; - } - NEEDBITS(16); -#ifdef GUNZIP - if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ - state->check = crc32(0L, Z_NULL, 0); - CRC2(state->check, hold); - INITBITS(); - state->mode = FLAGS; - break; - } - state->flags = 0; /* expect zlib header */ - if (state->head != Z_NULL) - state->head->done = -1; - if (!(state->wrap & 1) || /* check if zlib header allowed */ -#else - if ( -#endif - ((BITS(8) << 8) + (hold >> 8)) % 31) { - strm->msg = (char *)"incorrect header check"; - state->mode = BAD; - break; - } - if (BITS(4) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - DROPBITS(4); - len = BITS(4) + 8; - if (len > state->wbits) { - strm->msg = (char *)"invalid window size"; - state->mode = BAD; - break; - } - state->dmax = 1U << len; - Tracev((stderr, "inflate: zlib header ok\n")); - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = hold & 0x200 ? DICTID : TYPE; - INITBITS(); - break; -#ifdef GUNZIP - case FLAGS: - NEEDBITS(16); - state->flags = (int)(hold); - if ((state->flags & 0xff) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - if (state->flags & 0xe000) { - strm->msg = (char *)"unknown header flags set"; - state->mode = BAD; - break; - } - if (state->head != Z_NULL) - state->head->text = (int)((hold >> 8) & 1); - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = TIME; - case TIME: - NEEDBITS(32); - if (state->head != Z_NULL) - state->head->time = hold; - if (state->flags & 0x0200) CRC4(state->check, hold); - INITBITS(); - state->mode = OS; - case OS: - NEEDBITS(16); - if (state->head != Z_NULL) { - state->head->xflags = (int)(hold & 0xff); - state->head->os = (int)(hold >> 8); - } - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = EXLEN; - case EXLEN: - if (state->flags & 0x0400) { - NEEDBITS(16); - state->length = (unsigned)(hold); - if (state->head != Z_NULL) - state->head->extra_len = (unsigned)hold; - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - } - else if (state->head != Z_NULL) - state->head->extra = Z_NULL; - state->mode = EXTRA; - case EXTRA: - if (state->flags & 0x0400) { - copy = state->length; - if (copy > have) copy = have; - if (copy) { - if (state->head != Z_NULL && - state->head->extra != Z_NULL) { - len = state->head->extra_len - state->length; - zmemcpy(state->head->extra + len, next, - len + copy > state->head->extra_max ? - state->head->extra_max - len : copy); - } - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - state->length -= copy; - } - if (state->length) goto inf_leave; - } - state->length = 0; - state->mode = NAME; - case NAME: - if (state->flags & 0x0800) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->name != Z_NULL && - state->length < state->head->name_max) - state->head->name[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->name = Z_NULL; - state->length = 0; - state->mode = COMMENT; - case COMMENT: - if (state->flags & 0x1000) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->comment != Z_NULL && - state->length < state->head->comm_max) - state->head->comment[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->comment = Z_NULL; - state->mode = HCRC; - case HCRC: - if (state->flags & 0x0200) { - NEEDBITS(16); - if (hold != (state->check & 0xffff)) { - strm->msg = (char *)"header crc mismatch"; - state->mode = BAD; - break; - } - INITBITS(); - } - if (state->head != Z_NULL) { - state->head->hcrc = (int)((state->flags >> 9) & 1); - state->head->done = 1; - } - strm->adler = state->check = crc32(0L, Z_NULL, 0); - state->mode = TYPE; - break; -#endif - case DICTID: - NEEDBITS(32); - strm->adler = state->check = REVERSE(hold); - INITBITS(); - state->mode = DICT; - case DICT: - if (state->havedict == 0) { - RESTORE(); - return Z_NEED_DICT; - } - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = TYPE; - case TYPE: - if (flush == Z_BLOCK) goto inf_leave; - case TYPEDO: - if (state->last) { - BYTEBITS(); - state->mode = CHECK; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - case STORED: - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - state->mode = COPY; - case COPY: - copy = state->length; - if (copy) { - if (copy > have) copy = have; - if (copy > left) copy = left; - if (copy == 0) goto inf_leave; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - break; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - case TABLE: - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - state->have = 0; - state->mode = LENLENS; - case LENLENS: - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - state->have = 0; - state->mode = CODELENS; - case CODELENS: - while (state->have < state->nlen + state->ndist) { - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.val < 16) { - NEEDBITS(this.bits); - DROPBITS(this.bits); - state->lens[state->have++] = this.val; - } - else { - if (this.val == 16) { - NEEDBITS(this.bits + 2); - DROPBITS(this.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = state->lens[state->have - 1]; - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (this.val == 17) { - NEEDBITS(this.bits + 3); - DROPBITS(this.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(this.bits + 7); - DROPBITS(this.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* build code tables */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - case LEN: - if (have >= 6 && left >= 258) { - RESTORE(); - inflate_fast(strm, out); - LOAD(); - break; - } - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.op && (this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - state->length = (unsigned)this.val; - if ((int)(this.op) == 0) { - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - state->mode = LIT; - break; - } - if (this.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - if (this.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - state->extra = (unsigned)(this.op) & 15; - state->mode = LENEXT; - case LENEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - state->mode = DIST; - case DIST: - for (;;) { - this = state->distcode[BITS(state->distbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if ((this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - if (this.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)this.val; - state->extra = (unsigned)(this.op) & 15; - state->mode = DISTEXT; - case DISTEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } -#ifdef INFLATE_STRICT - if (state->offset > state->dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - if (state->offset > state->whave + out - left) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - state->mode = MATCH; - case MATCH: - if (left == 0) goto inf_leave; - copy = out - left; - if (state->offset > copy) { /* copy from window */ - copy = state->offset - copy; - if (copy > state->write) { - copy -= state->write; - from = state->window + (state->wsize - copy); - } - else - from = state->window + (state->write - copy); - if (copy > state->length) copy = state->length; - } - else { /* copy from output */ - from = put - state->offset; - copy = state->length; - } - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = *from++; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; - case LIT: - if (left == 0) goto inf_leave; - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - case CHECK: - if (state->wrap) { - NEEDBITS(32); - out -= left; - strm->total_out += out; - state->total += out; - if (out) - strm->adler = state->check = - UPDATE(state->check, put - out, out); - out = left; - if (( -#ifdef GUNZIP - state->flags ? hold : -#endif - REVERSE(hold)) != state->check) { - strm->msg = (char *)"incorrect data check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: check matches trailer\n")); - } -#ifdef GUNZIP - state->mode = LENGTH; - case LENGTH: - if (state->wrap && state->flags) { - NEEDBITS(32); - if (hold != (state->total & 0xffffffffUL)) { - strm->msg = (char *)"incorrect length check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: length matches trailer\n")); - } -#endif - state->mode = DONE; - case DONE: - ret = Z_STREAM_END; - goto inf_leave; - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: - return Z_STREAM_ERROR; - } - - /* - Return from inflate(), updating the total counts and the check value. - If there was no progress during the inflate() call, return a buffer - error. Call updatewindow() to create and/or update the window state. - Note: a memory error from inflate() is non-recoverable. - */ - inf_leave: - RESTORE(); - if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) - if (updatewindow(strm, out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - in -= strm->avail_in; - out -= strm->avail_out; - strm->total_in += in; - strm->total_out += out; - state->total += out; - if (state->wrap && out) - strm->adler = state->check = - UPDATE(state->check, strm->next_out - out, out); - strm->data_type = state->bits + (state->last ? 64 : 0) + - (state->mode == TYPE ? 128 : 0); - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) - ret = Z_BUF_ERROR; - return ret; -} - -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->window != Z_NULL) ZFREE(strm, state->window); - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ - struct inflate_state FAR *state; - unsigned long id; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->wrap != 0 && state->mode != DICT) - return Z_STREAM_ERROR; - - /* check for correct dictionary id */ - if (state->mode == DICT) { - id = adler32(0L, Z_NULL, 0); - id = adler32(id, dictionary, dictLength); - if (id != state->check) - return Z_DATA_ERROR; - } - - /* copy dictionary to window */ - if (updatewindow(strm, strm->avail_out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - if (dictLength > state->wsize) { - zmemcpy(state->window, dictionary + dictLength - state->wsize, - state->wsize); - state->whave = state->wsize; - } - else { - zmemcpy(state->window + state->wsize - dictLength, dictionary, - dictLength); - state->whave = dictLength; - } - state->havedict = 1; - Tracev((stderr, "inflate: dictionary set\n")); - return Z_OK; -} - -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ - struct inflate_state FAR *state; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; - - /* save header structure */ - state->head = head; - head->done = 0; - return Z_OK; -} - -/* - Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found - or when out of input. When called, *have is the number of pattern bytes - found in order so far, in 0..3. On return *have is updated to the new - state. If on return *have equals four, then the pattern was found and the - return value is how many bytes were read including the last byte of the - pattern. If *have is less than four, then the pattern has not been found - yet and the return value is len. In the latter case, syncsearch() can be - called again with more data and the *have state. *have is initialized to - zero for the first call. - */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -unsigned char FAR *buf; -unsigned len; -{ - unsigned got; - unsigned next; - - got = *have; - next = 0; - while (next < len && got < 4) { - if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) - got++; - else if (buf[next]) - got = 0; - else - got = 4 - got; - next++; - } - *have = got; - return next; -} - -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ - unsigned len; /* number of bytes to look at or looked at */ - unsigned long in, out; /* temporary to save total_in and total_out */ - unsigned char buf[4]; /* to restore bit buffer to byte string */ - struct inflate_state FAR *state; - - /* check parameters */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; - - /* if first time, start search in bit buffer */ - if (state->mode != SYNC) { - state->mode = SYNC; - state->hold <<= state->bits & 7; - state->bits -= state->bits & 7; - len = 0; - while (state->bits >= 8) { - buf[len++] = (unsigned char)(state->hold); - state->hold >>= 8; - state->bits -= 8; - } - state->have = 0; - syncsearch(&(state->have), buf, len); - } - - /* search available input */ - len = syncsearch(&(state->have), strm->next_in, strm->avail_in); - strm->avail_in -= len; - strm->next_in += len; - strm->total_in += len; - - /* return no joy or set up to restart inflate() on a new block */ - if (state->have != 4) return Z_DATA_ERROR; - in = strm->total_in; out = strm->total_out; - inflateReset(strm); - strm->total_in = in; strm->total_out = out; - state->mode = TYPE; - return Z_OK; -} - -/* - Returns true if inflate is currently at the end of a block generated by - Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - implementation to provide an additional safety check. PPP uses - Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored - block. When decompressing, PPP checks that at the end of input packet, - inflate is waiting for these length bytes. - */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - return state->mode == STORED && state->bits == 0; -} - -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ - struct inflate_state FAR *state; - struct inflate_state FAR *copy; - unsigned char FAR *window; - unsigned wsize; - - /* check input */ - if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || - source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)source->state; - - /* allocate space */ - copy = (struct inflate_state FAR *) - ZALLOC(source, 1, sizeof(struct inflate_state)); - if (copy == Z_NULL) return Z_MEM_ERROR; - window = Z_NULL; - if (state->window != Z_NULL) { - window = (unsigned char FAR *) - ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); - if (window == Z_NULL) { - ZFREE(source, copy); - return Z_MEM_ERROR; - } - } - - /* copy state */ - zmemcpy(dest, source, sizeof(z_stream)); - zmemcpy(copy, state, sizeof(struct inflate_state)); - if (state->lencode >= state->codes && - state->lencode <= state->codes + ENOUGH - 1) { - copy->lencode = copy->codes + (state->lencode - state->codes); - copy->distcode = copy->codes + (state->distcode - state->codes); - } - copy->next = copy->codes + (state->next - state->codes); - if (window != Z_NULL) { - wsize = 1U << state->wbits; - zmemcpy(window, state->window, wsize); - } - copy->window = window; - dest->state = (struct internal_state FAR *)copy; - return Z_OK; -} diff --git a/sourcepawn/compiler/zlib/inflate.h b/sourcepawn/compiler/zlib/inflate.h deleted file mode 100644 index fbbc8714..00000000 --- a/sourcepawn/compiler/zlib/inflate.h +++ /dev/null @@ -1,115 +0,0 @@ -/* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip decoding - should be left enabled. */ -#ifndef NO_GZIP -# define GUNZIP -#endif - -/* Possible inflate modes between inflate() calls */ -typedef enum { - HEAD, /* i: waiting for magic header */ - FLAGS, /* i: waiting for method and flags (gzip) */ - TIME, /* i: waiting for modification time (gzip) */ - OS, /* i: waiting for extra flags and operating system (gzip) */ - EXLEN, /* i: waiting for extra length (gzip) */ - EXTRA, /* i: waiting for extra bytes (gzip) */ - NAME, /* i: waiting for end of file name (gzip) */ - COMMENT, /* i: waiting for end of comment (gzip) */ - HCRC, /* i: waiting for header crc (gzip) */ - DICTID, /* i: waiting for dictionary check value */ - DICT, /* waiting for inflateSetDictionary() call */ - TYPE, /* i: waiting for type bits, including last-flag bit */ - TYPEDO, /* i: same, but skip check to exit inflate on new block */ - STORED, /* i: waiting for stored size (length and complement) */ - COPY, /* i/o: waiting for input or output to copy stored block */ - TABLE, /* i: waiting for dynamic block table lengths */ - LENLENS, /* i: waiting for code length code lengths */ - CODELENS, /* i: waiting for length/lit and distance code lengths */ - LEN, /* i: waiting for length/lit code */ - LENEXT, /* i: waiting for length extra bits */ - DIST, /* i: waiting for distance code */ - DISTEXT, /* i: waiting for distance extra bits */ - MATCH, /* o: waiting for output space to copy string */ - LIT, /* o: waiting for output space to write literal */ - CHECK, /* i: waiting for 32-bit check value */ - LENGTH, /* i: waiting for 32-bit length (gzip) */ - DONE, /* finished check, done -- remain here until reset */ - BAD, /* got a data error -- remain here until reset */ - MEM, /* got an inflate() memory error -- remain here until reset */ - SYNC /* looking for synchronization bytes to restart inflate() */ -} inflate_mode; - -/* - State transitions between above modes - - - (most modes can go to the BAD or MEM mode -- not shown for clarity) - - Process header: - HEAD -> (gzip) or (zlib) - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME - NAME -> COMMENT -> HCRC -> TYPE - (zlib) -> DICTID or TYPE - DICTID -> DICT -> TYPE - Read deflate blocks: - TYPE -> STORED or TABLE or LEN or CHECK - STORED -> COPY -> TYPE - TABLE -> LENLENS -> CODELENS -> LEN - Read deflate codes: - LEN -> LENEXT or LIT or TYPE - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN - LIT -> LEN - Process trailer: - CHECK -> LENGTH -> DONE - */ - -/* state maintained between inflate() calls. Approximately 7K bytes. */ -struct inflate_state { - inflate_mode mode; /* current inflate mode */ - int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags (0 if zlib) */ - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - unsigned long check; /* protected copy of check value */ - unsigned long total; /* protected copy of output count */ - gz_headerp head; /* where to save gzip header information */ - /* sliding window */ - unsigned wbits; /* log base 2 of requested window size */ - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned write; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - /* bit accumulator */ - unsigned long hold; /* input bit accumulator */ - unsigned bits; /* number of bits in "in" */ - /* for string and stored block copying */ - unsigned length; /* literal or length of data to copy */ - unsigned offset; /* distance back to copy string from */ - /* for table and code decoding */ - unsigned extra; /* extra bits needed */ - /* fixed and dynamic code tables */ - code const FAR *lencode; /* starting table for length/literal codes */ - code const FAR *distcode; /* starting table for distance codes */ - unsigned lenbits; /* index bits for lencode */ - unsigned distbits; /* index bits for distcode */ - /* dynamic table building */ - unsigned ncode; /* number of code length code lengths */ - unsigned nlen; /* number of length code lengths */ - unsigned ndist; /* number of distance code lengths */ - unsigned have; /* number of code lengths in lens[] */ - code FAR *next; /* next available space in codes[] */ - unsigned short lens[320]; /* temporary storage for code lengths */ - unsigned short work[288]; /* work area for code table building */ - code codes[ENOUGH]; /* space for code tables */ -}; diff --git a/sourcepawn/compiler/zlib/inftrees.c b/sourcepawn/compiler/zlib/inftrees.c deleted file mode 100644 index a1406443..00000000 --- a/sourcepawn/compiler/zlib/inftrees.c +++ /dev/null @@ -1,330 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include -#include "zutil.h" -#include "inftrees.h" - -#define MAXBITS 15 - -const char inflate_copyright[] = - " inflate 1.2.3 Copyright 1995-2005 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* - Build a set of tables to decode the provided canonical Huffman code. - The code lengths are lens[0..codes-1]. The result starts at *table, - whose indices are 0..2^bits-1. work is a writable array of at least - lens shorts, which is used as a work area. type is the type of code - to be generated, CODES, LENS, or DISTS. On return, zero is success, - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table - on return points to the next available entry's address. bits is the - requested root table index bits, and on return it is the actual root - table index bits. It will differ if the request is greater than the - longest code or if it is less than the shortest code. - */ -int inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ - unsigned len; /* a code's length in bits */ - unsigned sym; /* index of code symbols */ - unsigned min, max; /* minimum and maximum code lengths */ - unsigned root; /* number of index bits for root table */ - unsigned curr; /* number of index bits for current table */ - unsigned drop; /* code bits to drop for sub-table */ - int left; /* number of prefix codes available */ - unsigned used; /* code entries in table used */ - unsigned huff; /* Huffman code */ - unsigned incr; /* for incrementing code, index */ - unsigned fill; /* index for replicating entries */ - unsigned low; /* low bits for current root entry */ - unsigned mask; /* mask for low root bits */ - code this; /* table entry for duplication */ - code FAR *next; /* next available space in table */ - const unsigned short FAR *base; /* base value table to use */ - const unsigned short FAR *extra; /* extra bits table to use */ - int end; /* use base and extra for symbol > end */ - unsigned short count[MAXBITS+1]; /* number of codes of each length */ - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ - static const unsigned short lbase[31] = { /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - static const unsigned short lext[31] = { /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196}; - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0}; - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64}; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) - count[len] = 0; - for (sym = 0; sym < codes; sym++) - count[lens[sym]]++; - - /* bound code lengths, force root to be within code lengths */ - root = *bits; - for (max = MAXBITS; max >= 1; max--) - if (count[max] != 0) break; - if (root > max) root = max; - if (max == 0) { /* no symbols to code at all */ - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)1; - this.val = (unsigned short)0; - *(*table)++ = this; /* make a table to force an error */ - *(*table)++ = this; - *bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min <= MAXBITS; min++) - if (count[min] != 0) break; - if (root < min) root = min; - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) return -1; /* over-subscribed */ - } - if (left > 0 && (type == CODES || max != 1)) - return -1; /* incomplete set */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + count[len]; - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked when a LENS table is being made - against the space in *table, ENOUGH, minus the maximum space needed by - the worst case distance code, MAXD. This should never happen, but the - sufficiency of ENOUGH has not been proven exhaustively, hence the check. - This assumes that when type == LENS, bits == 9. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - switch (type) { - case CODES: - base = extra = work; /* dummy value--not used */ - end = 19; - break; - case LENS: - base = lbase; - base -= 257; - extra = lext; - extra -= 257; - end = 256; - break; - default: /* DISTS */ - base = dbase; - extra = dext; - end = -1; - } - - /* initialize state for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = *table; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = (unsigned)(-1); /* trigger new sub-table when len > root */ - used = 1U << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if (type == LENS && used >= ENOUGH - MAXD) - return 1; - - /* process all codes and make table entries */ - for (;;) { - /* create table entry */ - this.bits = (unsigned char)(len - drop); - if ((int)(work[sym]) < end) { - this.op = (unsigned char)0; - this.val = work[sym]; - } - else if ((int)(work[sym]) > end) { - this.op = (unsigned char)(extra[work[sym]]); - this.val = base[work[sym]]; - } - else { - this.op = (unsigned char)(32 + 64); /* end of block */ - this.val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1U << (len - drop); - fill = 1U << curr; - min = fill; /* save offset to next table */ - do { - fill -= incr; - next[(huff >> drop) + fill] = this; - } while (fill != 0); - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - - /* go to next symbol, update count, len */ - sym++; - if (--(count[len]) == 0) { - if (len == max) break; - len = lens[work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) != low) { - /* if first time, transition to sub-tables */ - if (drop == 0) - drop = root; - - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = (int)(1 << curr); - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) break; - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1U << curr; - if (type == LENS && used >= ENOUGH - MAXD) - return 1; - - /* point entry in root table to sub-table */ - low = huff & mask; - (*table)[low].op = (unsigned char)curr; - (*table)[low].bits = (unsigned char)root; - (*table)[low].val = (unsigned short)(next - *table); - } - } - - /* - Fill in rest of table for incomplete codes. This loop is similar to the - loop above in incrementing huff for table indices. It is assumed that - len is equal to curr + drop, so there is no loop needed to increment - through high index bits. When the current sub-table is filled, the loop - drops back to the root table to fill in any remaining entries there. - */ - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)(len - drop); - this.val = (unsigned short)0; - while (huff != 0) { - /* when done with sub-table, drop back to root table */ - if (drop != 0 && (huff & mask) != low) { - drop = 0; - len = root; - next = *table; - this.bits = (unsigned char)len; - } - - /* put invalid code marker in table */ - next[huff >> drop] = this; - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - } - - /* set return parameters */ - *table += used; - *bits = root; - return 0; -} diff --git a/sourcepawn/compiler/zlib/inftrees.h b/sourcepawn/compiler/zlib/inftrees.h deleted file mode 100644 index dc0fd567..00000000 --- a/sourcepawn/compiler/zlib/inftrees.h +++ /dev/null @@ -1,55 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Structure for decoding tables. Each entry provides either the - information needed to do the operation requested by the code that - indexed that table entry, or it provides a pointer to another - table that indexes more bits of the code. op indicates whether - the entry is a pointer to another table, a literal, a length or - distance, an end-of-block, or an invalid code. For a table - pointer, the low four bits of op is the number of index bits of - that table. For a length or distance, the low four bits of op - is the number of extra bits to get after the code. bits is - the number of bits in this code or part of the code to drop off - of the bit buffer. val is the actual byte to output in the case - of a literal, the base length or distance, or the offset from - the current table to the next table. Each entry is four bytes. */ -typedef struct { - unsigned char op; /* operation, extra bits, table bits */ - unsigned char bits; /* bits in this part of the code */ - unsigned short val; /* offset in table or code value */ -} code; - -/* op values as set by inflate_table(): - 00000000 - literal - 0000tttt - table link, tttt != 0 is the number of table index bits - 0001eeee - length or distance, eeee is the number of extra bits - 01100000 - end of block - 01000000 - invalid code - */ - -/* Maximum size of dynamic tree. The maximum found in a long but non- - exhaustive search was 1444 code structures (852 for length/literals - and 592 for distances, the latter actually the result of an - exhaustive search). The true maximum is not known, but the value - below is more than safe. */ -#define ENOUGH 2048 -#define MAXD 592 - -/* Type of code to build for inftable() */ -typedef enum { - CODES, - LENS, - DISTS -} codetype; - -extern int inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); diff --git a/sourcepawn/compiler/zlib/trees.c b/sourcepawn/compiler/zlib/trees.c deleted file mode 100644 index 6ca02864..00000000 --- a/sourcepawn/compiler/zlib/trees.c +++ /dev/null @@ -1,1220 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2005 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in a compressed form which is itself - * a Huffman encoding of the lengths of all the code strings (in - * ascending order by source values). The actual code strings are - * reconstructed from the lengths in the inflate process, as described - * in the deflate specification. - * - * REFERENCES - * - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - */ - -/* @(#) $Id$ */ - -/* #define GEN_TREES_H */ - -#include -#include "deflate.h" - -#ifdef DEBUG -# include -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local const int extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -local const uch bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -#define Buf_size (8 * 2*sizeof(char)) -/* Number of bits used within bi_buf. (bi_buf might be implemented on - * more than 16 bits on some systems.) - */ - -/* =========================================================================== - * Local data. These are initialized only once. - */ - -#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ - -#if defined(GEN_TREES_H) || !defined(STDC) -/* non ANSI compilers may not accept trees.h */ - -local ct_data static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init - * below). - */ - -local ct_data static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -uch _dist_code[DIST_CODE_LEN]; -/* Distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -uch _length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local int base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -#else -# include "trees.h" -#endif /* GEN_TREES_H */ - -struct static_tree_desc_s { - const ct_data *static_tree; /* static tree or NULL */ - const intf *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ -}; - -local static_tree_desc static_l_desc = -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; - -local static_tree_desc static_d_desc = -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; - -local static_tree_desc static_bl_desc = -{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, ct_data *ltree, - ct_data *dtree)); -local void set_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned value, int length)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); -local void copy_block OF((deflate_state *s, charf *buf, unsigned len, - int header)); - -#ifdef GEN_TREES_H -local void gen_trees_header OF((void)); -#endif - -#ifndef DEBUG -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* DEBUG */ -# define send_code(s, c, tree) \ - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(s, tree[c].Code, tree[c].Len); } -#endif - -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -#ifdef DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - Tracevv((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; - - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (s->bi_valid > (int)Buf_size - length) { - s->bi_buf |= (value << s->bi_valid); - put_short(s, s->bi_buf); - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); - s->bi_valid += length - Buf_size; - } else { - s->bi_buf |= value << s->bi_valid; - s->bi_valid += length; - } -} -#else /* !DEBUG */ - -#define send_bits(s, value, length) \ -{ int len = length;\ - if (s->bi_valid > (int)Buf_size - len) {\ - int val = value;\ - s->bi_buf |= (val << s->bi_valid);\ - put_short(s, s->bi_buf);\ - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ - s->bi_valid += len - Buf_size;\ - } else {\ - s->bi_buf |= (value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* DEBUG */ - - -/* the arguments must not have side effects */ - -/* =========================================================================== - * Initialize the various 'constant' tables. - */ -local void tr_static_init() -{ -#if defined(GEN_TREES_H) || !defined(STDC) - static int static_init_done = 0; - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - if (static_init_done) return; - - /* For some embedded targets, global variables are not initialized: */ - static_l_desc.static_tree = static_ltree; - static_l_desc.extra_bits = extra_lbits; - static_d_desc.static_tree = static_dtree; - static_d_desc.extra_bits = extra_dbits; - static_bl_desc.extra_bits = extra_blbits; - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - _dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse((unsigned)n, 5); - } - static_init_done = 1; - -# ifdef GEN_TREES_H - gen_trees_header(); -# endif -#endif /* defined(GEN_TREES_H) || !defined(STDC) */ -} - -/* =========================================================================== - * Genererate the file trees.h describing the static trees. - */ -#ifdef GEN_TREES_H -# ifndef DEBUG -# include -# endif - -# define SEPARATOR(i, last, width) \ - ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) - -void gen_trees_header() -{ - FILE *header = fopen("trees.h", "w"); - int i; - - Assert (header != NULL, "Can't open trees.h"); - fprintf(header, - "/* header created automatically with -DGEN_TREES_H */\n\n"); - - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); - for (i = 0; i < L_CODES+2; i++) { - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); - } - - fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); - } - - fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); - for (i = 0; i < DIST_CODE_LEN; i++) { - fprintf(header, "%2u%s", _dist_code[i], - SEPARATOR(i, DIST_CODE_LEN-1, 20)); - } - - fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - fprintf(header, "%2u%s", _length_code[i], - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); - } - - fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); - for (i = 0; i < LENGTH_CODES; i++) { - fprintf(header, "%1u%s", base_length[i], - SEPARATOR(i, LENGTH_CODES-1, 20)); - } - - fprintf(header, "local const int base_dist[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "%5u%s", base_dist[i], - SEPARATOR(i, D_CODES-1, 10)); - } - - fclose(header); -} -#endif /* GEN_TREES_H */ - -/* =========================================================================== - * Initialize the tree data structures for a new zlib stream. - */ -void _tr_init(s) - deflate_state *s; -{ - tr_static_init(); - - s->l_desc.dyn_tree = s->dyn_ltree; - s->l_desc.stat_desc = &static_l_desc; - - s->d_desc.dyn_tree = s->dyn_dtree; - s->d_desc.stat_desc = &static_d_desc; - - s->bl_desc.dyn_tree = s->bl_tree; - s->bl_desc.stat_desc = &static_bl_desc; - - s->bi_buf = 0; - s->bi_valid = 0; - s->last_eob_len = 8; /* enough lookahead for inflate */ -#ifdef DEBUG - s->compressed_len = 0L; - s->bits_sent = 0L; -#endif - - /* Initialize the first block of the first file: */ - init_block(s); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->last_lit = s->matches = 0; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(s, tree, top) \ -{\ - top = s->heap[SMALLEST]; \ - s->heap[SMALLEST] = s->heap[s->heap_len--]; \ - pqdownheap(s, tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m, depth) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = s->heap[k]; - int j = k << 1; /* left son of k */ - while (j <= s->heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < s->heap_len && - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { - j++; - } - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, s->heap[j], s->depth)) break; - - /* Exchange v with the smallest son */ - s->heap[k] = s->heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - s->heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - ct_data *tree = desc->dyn_tree; - int max_code = desc->max_code; - const ct_data *stree = desc->stat_desc->static_tree; - const intf *extra = desc->stat_desc->extra_bits; - int base = desc->stat_desc->extra_base; - int max_length = desc->stat_desc->max_length; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - - for (h = s->heap_max+1; h < HEAP_SIZE; h++) { - n = s->heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - s->bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - s->opt_len += (ulg)f * (bits + xbits); - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); - } - if (overflow == 0) return; - - Trace((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ - s->bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = s->bl_count[bits]; - while (n != 0) { - m = s->heap[--h]; - if (m > max_code) continue; - if ((unsigned) tree[m].Len != (unsigned) bits) { - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s->opt_len += ((long)bits - (long)tree[m].Len) - *(long)tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; - const ct_data *stree = desc->stat_desc->static_tree; - int elems = desc->stat_desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node; /* new node being created */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - s->heap_len = 0, s->heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - s->heap[++(s->heap_len)] = max_code = n; - s->depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (s->heap_len < 2) { - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); - tree[node].Freq = 1; - s->depth[node] = 0; - s->opt_len--; if (stree) s->static_len -= stree[node].Len; - /* node is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - node = elems; /* next internal node of the tree */ - do { - pqremove(s, tree, n); /* n = node of least frequency */ - m = s->heap[SMALLEST]; /* m = node of next least frequency */ - - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ - s->heap[--(s->heap_max)] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? - s->depth[n] : s->depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == s->bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - s->heap[SMALLEST] = node++; - pqdownheap(s, tree, SMALLEST); - - } while (s->heap_len >= 2); - - s->heap[--(s->heap_max)] = s->heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen(s, (tree_desc *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data *)tree, max_code, s->bl_count); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. - */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - s->bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) s->bl_tree[curlen].Freq++; - s->bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - s->bl_tree[REPZ_3_10].Freq++; - } else { - s->bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(s, curlen, s->bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(s, curlen, s->bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); - - } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); - - } else { - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree(s) - deflate_state *s; -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); - - /* Build the bit length tree: */ - build_tree(s, (tree_desc *)(&(s->bl_desc))); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*(max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", - s->opt_len, s->static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); -} - -/* =========================================================================== - * Send a stored block - */ -void _tr_stored_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ -#ifdef DEBUG - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; - s->compressed_len += (stored_len + 4) << 3; -#endif - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ -} - -/* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - * The current inflate code requires 9 bits of lookahead. If the - * last two codes for the previous block (real code plus EOB) were coded - * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode - * the last real code. In this case we send two empty static blocks instead - * of one. (There are no problems if the previous block is stored or fixed.) - * To simplify the code, we assume the worst case of last real code encoded - * on one bit only. - */ -void _tr_align(s) - deflate_state *s; -{ - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ -#endif - bi_flush(s); - /* Of the 10 bits for the empty block, we have already sent - * (10 - bi_valid) bits. The lookahead for the last real code (before - * the EOB of the previous block) was thus at least one plus the length - * of the EOB plus what we have just sent of the empty static block. - */ - if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; -#endif - bi_flush(s); - } - s->last_eob_len = 7; -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. - */ -void _tr_flush_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex = 0; /* index of last bit length code of non zero freq */ - - /* Build the Huffman trees unless a stored block is forced */ - if (s->level > 0) { - - /* Check if the file is binary or text */ - if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN) - set_data_type(s); - - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); - - /* Determine the best encoding. Compute the block lengths in bytes. */ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; - - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - } else { - Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ - } - -#ifdef FORCE_STORED - if (buf != (char*)0) { /* force stored block */ -#else - if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - _tr_stored_block(s, buf, stored_len, eof); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+eof, 3); - compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->static_len; -#endif - } else { - send_bits(s, (DYN_TREES<<1)+eof, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); - compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->opt_len; -#endif - } - Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - /* The above check is made mod 2^32, for files larger than 512 MB - * and uLong implemented on 32 bits. - */ - init_block(s); - - if (eof) { - bi_windup(s); -#ifdef DEBUG - s->compressed_len += 7; /* align on byte boundary */ -#endif - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - s->compressed_len-7*eof)); -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - s->d_buf[s->last_lit] = (ush)dist; - s->l_buf[s->last_lit++] = (uch)lc; - if (dist == 0) { - /* lc is the unmatched char */ - s->dyn_ltree[lc].Freq++; - } else { - s->matches++; - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST(s) && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; - s->dyn_dtree[d_code(dist)].Freq++; - } - -#ifdef TRUNCATE_BLOCK - /* Try to guess if it is profitable to stop the current block here */ - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)s->last_lit*8L; - ulg in_length = (ulg)((long)s->strstart - s->block_start); - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * - (5L+extra_dbits[dcode]); - } - out_length >>= 3; - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - s->last_lit, in_length, out_length, - 100L - out_length*100L/in_length)); - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; - } -#endif - return (s->last_lit == s->lit_bufsize-1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - ct_data *ltree; /* literal tree */ - ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->last_lit != 0) do { - dist = s->d_buf[lx]; - lc = s->l_buf[lx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, - "pendingBuf overflow"); - - } while (lx < s->last_lit); - - send_code(s, END_BLOCK, ltree); - s->last_eob_len = ltree[END_BLOCK].Len; -} - -/* =========================================================================== - * Set the data type to BINARY or TEXT, using a crude approximation: - * set it to Z_TEXT if all symbols are either printable characters (33 to 255) - * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise. - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local void set_data_type(s) - deflate_state *s; -{ - int n; - - for (n = 0; n < 9; n++) - if (s->dyn_ltree[n].Freq != 0) - break; - if (n == 9) - for (n = 14; n < 32; n++) - if (s->dyn_ltree[n].Freq != 0) - break; - s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef DEBUG - s->bits_sent = (s->bits_sent+7) & ~7; -#endif -} - -/* =========================================================================== - * Copy a stored block, storing first the length and its - * one's complement if requested. - */ -local void copy_block(s, buf, len, header) - deflate_state *s; - charf *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(s); /* align on byte boundary */ - s->last_eob_len = 8; /* enough lookahead for inflate */ - - if (header) { - put_short(s, (ush)len); - put_short(s, (ush)~len); -#ifdef DEBUG - s->bits_sent += 2*16; -#endif - } -#ifdef DEBUG - s->bits_sent += (ulg)len<<3; -#endif - while (len--) { - put_byte(s, *buf++); - } -} diff --git a/sourcepawn/compiler/zlib/trees.h b/sourcepawn/compiler/zlib/trees.h deleted file mode 100644 index 1ca868b8..00000000 --- a/sourcepawn/compiler/zlib/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_TREES_H */ - -local const ct_data static_ltree[L_CODES+2] = { -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} -}; - -local const ct_data static_dtree[D_CODES] = { -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} -}; - -const uch _dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -local const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -local const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - diff --git a/sourcepawn/compiler/zlib/uncompr.c b/sourcepawn/compiler/zlib/uncompr.c deleted file mode 100644 index ad6db0a6..00000000 --- a/sourcepawn/compiler/zlib/uncompr.c +++ /dev/null @@ -1,61 +0,0 @@ -/* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-2003 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. -*/ -int ZEXPORT uncompress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - z_stream stream; - int err; - - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - err = inflateInit(&stream); - if (err != Z_OK) return err; - - err = inflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - inflateEnd(&stream); - if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) - return Z_DATA_ERROR; - return err; - } - *destLen = stream.total_out; - - err = inflateEnd(&stream); - return err; -} diff --git a/sourcepawn/compiler/zlib/zconf.h b/sourcepawn/compiler/zlib/zconf.h deleted file mode 100644 index 59b5e7a6..00000000 --- a/sourcepawn/compiler/zlib/zconf.h +++ /dev/null @@ -1,281 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ -# include /* for off_t */ -# include /* for SEEK_* and off_t */ -# ifdef VMS -# include /* for off_t */ -# endif -# define z_off_t off_t -#endif -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif -#ifndef z_off_t -# define z_off_t long -#endif - -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -# ifdef FAR -# undef FAR -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) -# pragma map(deflateInit_,"DEIN") -# pragma map(deflateInit2_,"DEIN2") -# pragma map(deflateEnd,"DEEND") -# pragma map(deflateBound,"DEBND") -# pragma map(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(compressBound,"CMBND") -# pragma map(inflate_table,"INTABL") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/sourcepawn/compiler/zlib/zlib.h b/sourcepawn/compiler/zlib/zlib.h deleted file mode 100644 index 62d0e467..00000000 --- a/sourcepawn/compiler/zlib/zlib.h +++ /dev/null @@ -1,1357 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.3, July 18th, 2005 - - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.3" -#define ZLIB_VERNUM 0x1230 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms will be added later and will have the same - stream interface. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never - crash even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce some - output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumualte before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In particular - avail_in is zero after the call if enough output space has been provided - before the call.) Flushing may degrade compression for some compression - algorithms and so it should be used only when necessary. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - the value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact - value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, - Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() stop - if and when it gets to the next deflate block boundary. When decoding the - zlib or gzip format, this will cause inflate() to return immediately after - the header and before the first block. When doing a raw inflate, inflate() - will go ahead and process the first block, and will return when it gets to - the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 - if inflate() is currently decoding the last block in the deflate stream, - plus 128 if inflate() returned immediately after decoding an end-of-block - code or decoding the complete header up to just before the first byte of the - deflate stream. The end-of-block will not be indicated until all of the - uncompressed data from that block has been written to strm->next_out. The - number of unused bits may in general be greater than seven, except when - bit 7 of data_type is set, in which case the number of unused bits will be - less than eight. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster approach - may be used for the single inflate() call. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the adler32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() will decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically. Any information - contained in the gzip header is not retained, so applications that need that - information should instead use raw inflate, see inflateInit2() below, or - inflateBack() and perform their own processing of the gzip header and - trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may then - call inflateSync() to look for a good compression block if a partial recovery - of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), - no header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as - Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy - parameter only affects the compression ratio but not the correctness of the - compressed output even if it is not set appropriately. Z_FIXED prevents the - use of dynamic Huffman codes, allowing for a simpler decoder for special - applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. In addition, the - current implementation of deflate will use at most the window size minus - 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different - strategy. If the compression level is changed, the input available so far - is compressed with the old level (and may be flushed); the new level will - take effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() - or deflateInit2(). This would be used to allocate an output buffer - for deflation in a single pass, and so would be called before deflate(). -*/ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the - bits leftover from a previous deflate stream when appending to it. As such, - this function can only be used for raw deflate, and must be used before the - first deflate() call after a deflateInit2() or deflateReset(). bits must be - less than or equal to 16, and that many of the least significant bits of - value will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is - a crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg - is set to null if there is no error message. inflateInit2 does not perform - any decompression apart from reading the zlib header if present: this will - be done by inflate(). (So next_in and avail_in may be modified, but next_out - and avail_out are unchanged.) -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been found, - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current current value of total_in which - indicates where valid compressed data was found. In the error case, the - application may repeatedly call inflateSync, providing more input each time, - until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. - The stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK can be used to - force inflate() to return immediately after header processing is complete - and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When - any of extra, name, or comment are not Z_NULL and the respective field is - not present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not - be allocated, or Z_VERSION_ERROR if the version of the library does not - match the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free - the allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects - only the raw deflate stream to decompress. This is different from the - normal behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format - error in the deflate stream (in which case strm->msg is set to indicate the - nature of the error), or Z_STREAM_ERROR if the stream was not properly - initialized. In the case of Z_BUF_ERROR, an input or output error can be - distinguished using strm->next_in which will be Z_NULL only if in() returned - an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to - out() returning non-zero. (in() will always be called before out(), so - strm->next_in is assured to be defined if out() returns non-zero.) Note - that inflateBack() cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the - basic stream-oriented functions. To simplify the interface, some - default options are assumed (compression level and memory usage, - standard memory allocation functions). The source code of these - utility functions can easily be modified if you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be at least the value returned - by compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before - a compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. -*/ - - -typedef voidp gzFile; - -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); -/* - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb") but can also include a compression level - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for - Huffman only compression as in "wb1h", or 'R' for run-length encoding - as in "wb1R". (See the description of deflateInit2 for more information - about the strategy parameter.) - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen() associates a gzFile with the file descriptor fd. File - descriptors are obtained from calls like open, dup, creat, pipe or - fileno (in the file has been previously opened with fopen). - The mode parameter is as in gzopen. - The next call of gzclose on the returned gzFile will also close the - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). The number of - uncompressed bytes written is limited to 4095. The caller should assure that - this limit is not exceeded. If it is exceeded, then gzprintf() will return - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() - because the secure snprintf() or vsnprintf() functions were not available. -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or - a newline character is read and transferred to buf, or an end-of-file - condition is encountered. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read again later. - Only one character of push-back is allowed. gzungetc() returns the - character pushed, or -1 on failure. gzungetc() will fail if a - character has been pushed but not read yet, or if c is -1. The pushed - character will be discarded if the stream is repositioned with gzseek() - or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. The return value is the zlib - error number (see function gzerror below). gzflush returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); -/* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); -/* - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns 1 if file is being read directly without decompression, otherwise - zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); -/* - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is NULL, this function returns the required initial - value for the for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - -/* - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - - -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/sourcepawn/compiler/zlib/zutil.c b/sourcepawn/compiler/zlib/zutil.c deleted file mode 100644 index 56e552f4..00000000 --- a/sourcepawn/compiler/zlib/zutil.c +++ /dev/null @@ -1,319 +0,0 @@ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include -#include "zutil.h" - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -const char * const z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; - - -const char * ZEXPORT zlibVersion() -{ - return ZLIB_VERSION; -} - -uLong ZEXPORT zlibCompileFlags() -{ - uLong flags; - - flags = 0; - switch (sizeof(uInt)) { - case 2: break; - case 4: flags += 1; break; - case 8: flags += 2; break; - default: flags += 3; - } - switch (sizeof(uLong)) { - case 2: break; - case 4: flags += 1 << 2; break; - case 8: flags += 2 << 2; break; - default: flags += 3 << 2; - } - switch (sizeof(voidpf)) { - case 2: break; - case 4: flags += 1 << 4; break; - case 8: flags += 2 << 4; break; - default: flags += 3 << 4; - } - switch (sizeof(z_off_t)) { - case 2: break; - case 4: flags += 1 << 6; break; - case 8: flags += 2 << 6; break; - default: flags += 3 << 6; - } -#ifdef DEBUG - flags += 1 << 8; -#endif -#if defined(ASMV) || defined(ASMINF) - flags += 1 << 9; -#endif -#ifdef ZLIB_WINAPI - flags += 1 << 10; -#endif -#ifdef BUILDFIXED - flags += 1 << 12; -#endif -#ifdef DYNAMIC_CRC_TABLE - flags += 1 << 13; -#endif -#ifdef NO_GZCOMPRESS - flags += 1L << 16; -#endif -#ifdef NO_GZIP - flags += 1L << 17; -#endif -#ifdef PKZIP_BUG_WORKAROUND - flags += 1L << 20; -#endif -#ifdef FASTEST - flags += 1L << 21; -#endif -#ifdef STDC -# ifdef NO_vsnprintf - flags += 1L << 25; -# ifdef HAS_vsprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_vsnprintf_void - flags += 1L << 26; -# endif -# endif -#else - flags += 1L << 24; -# ifdef NO_snprintf - flags += 1L << 25; -# ifdef HAS_sprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_snprintf_void - flags += 1L << 26; -# endif -# endif -#endif - return flags; -} - -#ifdef DEBUG - -# ifndef verbose -# define verbose 0 -# endif -int z_verbose = verbose; - -void z_error (m) - char *m; -{ - fprintf(stderr, "%s\n", m); - exit(1); -} -#endif - -/* exported to allow conversion of error code to string for compress() and - * uncompress() - */ -const char * ZEXPORT zError(err) - int err; -{ - return ERR_MSG(err); -} - -#if defined(_WIN32_WCE) - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. - */ - int errno = 0; -#endif - -#ifndef HAVE_MEMCPY - -void zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); -} - -int zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ - uInt j; - - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; -} - -void zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - - -#ifdef SYS16BIT - -#ifdef __TURBOC__ -/* Turbo C in 16-bit mode */ - -# define MY_ZCALLOC - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use zcfree(). - */ - -#define MAX_PTR 10 -/* 10*64K = 640K */ - -local int next_ptr = 0; - -typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; -} ptr_table; - -local ptr_table table[MAX_PTR]; -/* This table is used to remember the original form of pointers - * to large buffers (64K). Such pointers are normalized with a zero offset. - * Since MSDOS is not a preemptive multitasking OS, this table is not - * protected from concurrent access. This hack doesn't work anyway on - * a protected system like OS/2. Use Microsoft C instead. - */ - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - voidpf buf = opaque; /* just to make some compilers happy */ - ulg bsize = (ulg)items*size; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - int n; - if (*(ush*)&ptr != 0) { /* object < 64K */ - farfree(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - farfree(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - ptr = opaque; /* just to make some compilers happy */ - Assert(0, "zcfree: ptr not found"); -} - -#endif /* __TURBOC__ */ - - -#ifdef M_I86 -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - return _halloc((long)items, size); -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - _hfree(ptr); -} - -#endif /* M_I86 */ - -#endif /* SYS16BIT */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - if (opaque) items += size - size; /* make compiler happy */ - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : - (voidpf)calloc(items, size); -} - -void zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - free(ptr); - if (opaque) return; /* make compiler happy */ -} - -#endif /* MY_ZCALLOC */ diff --git a/sourcepawn/compiler/zlib/zutil.h b/sourcepawn/compiler/zlib/zutil.h deleted file mode 100644 index 0ba6e020..00000000 --- a/sourcepawn/compiler/zlib/zutil.h +++ /dev/null @@ -1,269 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#define ZLIB_INTERNAL -#include "zlib.h" - -#ifdef STDC -# ifndef _WIN32_WCE -# include -# endif -# include -# include -#endif -#ifdef NO_ERRNO_H -# ifdef _WIN32_WCE - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. We rename it to - * avoid conflict with other libraries that use the same workaround. - */ -# define errno z_errno -# endif - extern int errno; -#else -# ifndef _WIN32_WCE -# include -# endif -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -# ifdef M_I86 - #include -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# define vsnprintf _vsnprintf -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -#endif -#ifdef VMS -# define NO_vsnprintf -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int z_verbose; - extern void z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* ZUTIL_H */ diff --git a/sourcepawn/include/smx/smx-headers.h b/sourcepawn/include/smx/smx-headers.h deleted file mode 100644 index 2fb94235..00000000 --- a/sourcepawn/include/smx/smx-headers.h +++ /dev/null @@ -1,177 +0,0 @@ -// vim: set sts=2 ts=8 sw=2 tw=99 et: -// ============================================================================= -// SourcePawn -// 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 . -// -// 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 . - -#ifndef _INCLUDE_SPFILE_HEADERS_H -#define _INCLUDE_SPFILE_HEADERS_H - -#include -#include - -namespace sp { - -struct SmxConsts -{ - // SourcePawn File Format (SPFF) magic number. - static const uint32_t FILE_MAGIC = 0x53504646; - - // File format verison number. - // 0x0101 - SourcePawn 1.0; initial version used by SourceMod 1.0. - // 0x0102 - SourcePawn 1.1; used by SourceMod 1.1+. - // 0x0200 - Used by spcomp2. - // - // The major version bits (8-15) indicate a product number. Consumers should - // reject any version for a different product. - // - // The minor version bits (0-7) indicate a compatibility revision. Any minor - // version higher than the current version should be rejected. - static const uint16_t SP1_VERSION_1_0 = 0x0101; - static const uint16_t SP1_VERSION_1_1 = 0x0102; - static const uint16_t SP1_VERSION_1_7 = 0x0107; - static const uint16_t SP1_VERSION_MIN = SP1_VERSION_1_0; - static const uint16_t SP1_VERSION_MAX = SP1_VERSION_1_7; - static const uint16_t SP2_VERSION_MIN = 0x0200; - static const uint16_t SP2_VERSION_MAX = 0x0200; - - // Compression types. - static const uint8_t FILE_COMPRESSION_NONE = 0; - static const uint8_t FILE_COMPRESSION_GZ = 1; - - // SourcePawn 1. - static const uint8_t CODE_VERSION_JIT_1_0 = 9; - static const uint8_t CODE_VERSION_JIT_1_1 = 10; - static const uint8_t CODE_VERSION_JIT_1_7 = 11; - static const uint8_t CODE_VERSION_SP1_MIN = CODE_VERSION_JIT_1_0; - static const uint8_t CODE_VERSION_SP1_MAX = CODE_VERSION_JIT_1_1; - - // For SP1 consumers, the container version may not be checked, but usually - // the code version is. This constant allows newer containers to be rejected - // in those applications. - static const uint8_t CODE_VERSION_REJECT = 0x7F; -}; - -// These structures are byte-packed. -#if defined __GNUC__ -# pragma pack(1) -#else -# pragma pack(push) -# pragma pack(1) -#endif - -// The very first bytes in a .smx file. The .smx file format is a container for -// arbitrary sections, though to actually load a .smx file certain sections -// must be present. The on-disk format has four major regions, in order: -// 1. The header (sp_file_hdr_t). -// 2. The section list (sp_file_section_t). -// 3. The string table. -// 4. The section contents. -// -// Although any part of the file after the header can be compressed, by default -// only the section contents are, and the section list and string table are not. -typedef struct sp_file_hdr_s -{ - // Magic number and version number. - uint32_t magic; - uint16_t version; - - // disksize, imagesize, and dataoffs (at the end) describe a region of the - // file that may be compressed. The region must occur after the initial - // sp_file_hdr_t header. For SourceMod compatibility, the meanings are as - // follows. - // - // Without compression: - // imagesize is the amount of bytes that must be read into memory to parse - // the SMX container, starting from the first byte of the file. - // disksize is undefined. - // dataoffs is undefined. - // - // With compression: - // dataoffs is an offset to the start of the compression region. - // disksize is the length of the compressed region, in bytes, plus dataoffs. - // imagesize is the size of the entire SMX container after decompression. - // - // This means that at least |imagesize-dataoffs| must be allocated to - // decompress, and the compressed region's length is |datasize-dataoffs|. - // - // The compressed region should always be expanded "in-place". That is, to - // parse the container, the compressed bytes should be replaced with - // decompressed bytes. - // - // Note: This scheme may seem odd. It's a combination of historical debt and - // previously unspecified behavior. The original .amx file format contained - // an on-disk structure that supported an endian-agnostic variable-length - // encoding of its data section, and this structure was loaded directly into - // memory and used as the VM context. AMX Mod X later developed a container - // format called ".amxx" as a "universal binary" for 32-bit and 64-bit - // plugins. This format dropped compact encoding, but supported gzip. The - // disksize/imagesize oddness made its way to this file format. When .smx - // was created for SourceMod, it persisted even though AMX was dropped - // entirely. So it goes. - uint8_t compression; - uint32_t disksize; - uint32_t imagesize; - - // Number of named file sections. - uint8_t sections; - - // Offset to the string table. Each string is null-terminated. The string - // table is only used for strings related to parsing the container itself. - // For SourcePawn, a separate ".names" section exists for Pawn-specific data. - uint32_t stringtab; - - // Offset to where compression begins. - uint32_t dataoffs; -} sp_file_hdr_t; - -// Each section is written immediately after the header. -typedef struct sp_file_section_s -{ - uint32_t nameoffs; /**< Offset into the string table. */ - uint32_t dataoffs; /**< Offset into the file for the section contents. */ - uint32_t size; /**< Size of this section's contents. */ -} sp_file_section_t; - -// Code section. This is used only in SP1, but is emitted by default for legacy -// systems which check |codeversion| but not the SMX file version. -typedef struct sp_file_code_s -{ - uint32_t codesize; /**< Size of the code section. */ - uint8_t cellsize; /**< Cellsize in bytes. */ - uint8_t codeversion; /**< Version of opcodes supported. */ - uint16_t flags; /**< Flags. */ - uint32_t main; /**< Address to "main". */ - uint32_t code; /**< Offset to bytecode, relative to the start of this section. */ -} sp_file_code_t; - -#if defined __GNUC__ -# pragma pack() -#else -# pragma pack(pop) -#endif - -} // namespace sp - -#endif //_INCLUDE_SPFILE_HEADERS_H diff --git a/sourcepawn/include/smx/smx-rtti.h b/sourcepawn/include/smx/smx-rtti.h deleted file mode 100644 index 9b8dec22..00000000 --- a/sourcepawn/include/smx/smx-rtti.h +++ /dev/null @@ -1,218 +0,0 @@ -// vim: set sts=2 ts=8 sw=2 tw=99 et: -// ============================================================================= -// SourcePawn -// Copyright (C) 2004-2014 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 . -// -// 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 . - -#ifndef _INCLUDE_SPFILE_HEADERS_v2_H -#define _INCLUDE_SPFILE_HEADERS_v2_H - -#include - -namespace sp { - -// These structures are byte-packed. -#if defined __GNUC__ -# pragma pack(1) -#else -# pragma pack(push) -# pragma pack(1) -#endif - -// Tables present in smx v2: -// .names Blob of null-terminated strings. -// .methods Table of smx_method_t entries. -// .pcode Blob of smx_pcode_header_t entries. -// .globals Table of smx_global_var_t entries. -// .types Blob of type information. - -// TypeSpec is a variable-length encoding referenced anywhere that "typespec" -// is specified. -// -// Whenever a TypeSpec is referenced from outside the .types table, specifically -// as a "typeid", it has an encoding to save space: If the id is < 0x20, then -// the id is a single-byte TypeSpec. Otherwise, the |id - 0x20| is an offset -// into the .types section. -enum class TypeSpec : uint8_t -{ - // The void type is special in that it is not a storable type. - void_t = 0x0, - - // Standard C++ datatypes. - boolean = 0x1, - RESERVED_int8 = 0x2, - RESERVED_uint8 = 0x3, - RESERVED_int16 = 0x4, - RESERVED_uint16 = 0x5, - int32 = 0x6, - RESERVED_uint32 = 0x7, - RESERVED_int64 = 0x8, - RESERVED_uint64 = 0x9, - - // platform-width int and uint. - RESERVED_intptr = 0xA, - RESERVED_uintptr = 0xB, - - float32 = 0xC, - RESERVED_float64 = 0xD, - - // char8 is semantically an alias for int8. - char8 = 0xE, - - RESERVED_char32 = 0xF, // Full unicode point. - - RESERVED_string = 0x16, // String reference. - RESERVED_object = 0x17, // Opaque object reference. - - // Followed by an int32 index into the .classes table. - RESERVED_classdef = 0x40, - - // Followed by an int32 index into the .structs table. - RESERVED_structdef = 0x41, - - // Followed by: - // [int8 formalCount] ; Number of formal parameters, counting varargs. - // [typespec *formals] ; Sequence of formal parameter specifications. - // - // When the type spec is for a method definition (for example, the .method - // table), then each type in |formals| must begin with "named" (0x7e) or, - // if it is the last formal, may be "variadic" (0x7a). - method = 0x50, - - // Fixed arrays have their size as part of their type, are copied by-value, - // and passed by-reference. - // - // Followed by: - // typespec type ; Type specification of innermost elements. - // uint8 rank ; Number of dimensions - // int32* dims ; One dimension for each rank. - fixedarray = 0x60, - - // Arrays are true arrays. They are copied by-reference and passed by- - // reference. - // - // Followed by: - // typesec type ; Type specification of innermost elements. - // uint8 rank ; Number of dimensions. - RESERVED_array = 0x61, - - // Only legal as the initial byte or byte following "named" (0x7e) in a - // parameter for a method signature. - // - // Followed by a typespec. Only typespecs < 0x60 ar elegal. - byref = 0x70, - - // Only legal as the initial byte or byte following "named" (0x7e) in a - // parameter for a method signature. - // - // Followed by a typespec. - variadic = 0x7A, - - // Only legal as the initial byte in a parameter or local variable signature. - // - // Followed by: - // uint32 name ; Index into the .names section. - // typespec type ; Type. - named = 0x7E, - - // For readability, this may be emitted at the end of typespec lists. It must - // not be emitted at the end of nested typespecs. - terminator = 0x7F -}; - -// Flags for method definitions. -enum class MethodFlags : uint32_t -{ - STATIC = 0x1, - VARIADIC = 0x2, - PUBLIC = 0x4, - NATIVE = 0x8, - OPTIONAL = 0x10 -}; - -// Specifies an entry in the .methods table. -struct smx_method_t -{ - // Offset into the .names section. - uint32_t name; - - MethodFlags flags; - - // Offset into .types, which must point at a TypeSpec::method. - uint32_t typespec; - - // Offset into .pcode. If flags contains NATIVE, this must be 0. - uint32_t address; -}; - -enum class GlobalVarFlags : uint32_t -{ - PUBLIC = 0x04, - CONST = 0x08 -}; - -// Specifies an entry in the .globals table. -struct smx_global_var_t -{ - // Offset into the .names section. - uint32_t name; - - GlobalVarFlags flags; - - // TypeId of the global. - uint32_t type_id; -}; - -// Specifies the layout we expect at a valid pcode starting position. -struct smx_pcode_header_t -{ - // Must be 0. - uint32_t reserved; - - // Number of local variables. - uint16_t nlocals; - - // Maximum depth of the operand stack. - uint16_t max_depth; - - // Pointer to .types section where local information begins. - uint32_t local_specs; - - // Number of bytes of pcode in the method. - uint32_t length; -}; - -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// DO NOT DEFINE NEW STRUCTURES BELOW. -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -#if defined __GNUC__ -# pragma pack() -#else -# pragma pack(pop) -#endif - -} // namespace sp - -#endif // _INCLUDE_SPFILE_HEADERS_v2_H diff --git a/sourcepawn/include/smx/smx-v1-opcodes.h b/sourcepawn/include/smx/smx-v1-opcodes.h deleted file mode 100644 index 9ed2601d..00000000 --- a/sourcepawn/include/smx/smx-v1-opcodes.h +++ /dev/null @@ -1,266 +0,0 @@ -// vim: set sts=2 ts=8 sw=2 tw=99 et: -// ============================================================================= -// SourcePawn -// Copyright (C) 2004-2014 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 . -// -// 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 . - -#ifndef _INCLUDE_SPFILE_HEADERS_v1_opcodes_H -#define _INCLUDE_SPFILE_HEADERS_v1_opcodes_H - -#include -#include - -namespace sp { - -// Opcodes labelled "UNGEN" cannot be generated by the compiler. Quite a few, -// if they could, make little sense in the context of a JIT and could not -// work anyway. Opcodes technically present in sc4.c/sc7.c (respectively, -// the code emitter and peephole optimizer) are not necessarily ever generated. -// For example, lref.pri and lref.alt would be used if a reference could be -// stored in the global scope; but they can't, so they are unreachable. -// -// Most opcodes have been manually verified. A few have not, as they are only -// produced by the peephole optimizer, or not produced at all, or eliminated -// during optimization. We generate them anyway, just in case, but they have -// not been tested. -// lref.s.alt (phopt only) -// stor.alt (never) -// stor.s.alt (never) -// sref.s.alt (never) -// lidx.b (phopt only, probably impossible) -// idxaddr.b (phopt only, looks difficult) -// move.pri (eliminated in phopt) -// shl.c.pri (eliminated in phopt) -// shl.c.alt (eliminated in phopt) -// shr.c.pri (eliminated in phopt) -// shr.c.alt (eliminated in phopt) -// eq.c.alt (never) -// inc.alt (never) -// dec.alt (never) -// sdiv (never) -// nop (never in function bodies) -// -// Additionally, some opcodes which were supported in the earlier JIT are no -// longer supported because of the above: -// lref.pri/alt -// sref.pri/alt -// sign.pri/alt - -#define OPCODE_LIST(_) \ - _(NONE, "none") \ - _(LOAD_PRI, "load.pri") \ - _(LOAD_ALT, "load.alt") \ - _(LOAD_S_PRI, "load.s.pri") \ - _(LOAD_S_ALT, "load.s.alt") \ - _(UNGEN_LREF_PRI, "lref.pri") \ - _(UNGEN_LREF_ALT, "lref.alt") \ - _(LREF_S_PRI, "lref.s.pri") \ - _(LREF_S_ALT, "lref.s.alt") \ - _(LOAD_I, "load.i") \ - _(LODB_I, "lodb.i") \ - _(CONST_PRI, "const.pri") \ - _(CONST_ALT, "const.alt") \ - _(ADDR_PRI, "addr.pri") \ - _(ADDR_ALT, "addr.alt") \ - _(STOR_PRI, "stor.pri") \ - _(STOR_ALT, "stor.alt") \ - _(STOR_S_PRI, "stor.s.pri") \ - _(STOR_S_ALT, "stor.s.alt") \ - _(UNGEN_SREF_PRI, "sref.pri") \ - _(UNGEN_SREF_ALT, "sref.alt") \ - _(SREF_S_PRI, "sref.s.pri") \ - _(SREF_S_ALT, "sref.s.alt") \ - _(STOR_I, "stor.i") \ - _(STRB_I, "strb.i") \ - _(LIDX, "lidx") \ - _(LIDX_B, "lidx.b") \ - _(IDXADDR, "idxaddr") \ - _(IDXADDR_B, "idxaddr.b") \ - _(UNGEN_ALIGN_PRI,"align.pri") \ - _(UNGEN_ALIGN_ALT,"align.alt") \ - _(UNGEN_LCTRL, "lctrl") \ - _(UNGEN_SCTRL, "sctrl") \ - _(MOVE_PRI, "move.pri") \ - _(MOVE_ALT, "move.alt") \ - _(XCHG, "xchg") \ - _(PUSH_PRI, "push.pri") \ - _(PUSH_ALT, "push.alt") \ - _(UNGEN_PUSH_R, "push.r") \ - _(PUSH_C, "push.c") \ - _(PUSH, "push") \ - _(PUSH_S, "push.s") \ - _(POP_PRI, "pop.pri") \ - _(POP_ALT, "pop.alt") \ - _(STACK, "stack") \ - _(HEAP, "heap") \ - _(PROC, "proc") \ - _(UNGEN_RET, "ret") \ - _(RETN, "retn") \ - _(CALL, "call") \ - _(UNGEN_CALL_PRI, "call.pri") \ - _(JUMP, "jump") \ - _(UNGEN_JREL, "jrel") \ - _(JZER, "jzer") \ - _(JNZ, "jnz") \ - _(JEQ, "jeq") \ - _(JNEQ, "jneq") \ - _(UNGEN_JLESS, "jsless") \ - _(UNGEN_JLEQ, "jleq") \ - _(UNGEN_JGRTR, "jgrtr") \ - _(UNGEN_JGEQ, "jgeq") \ - _(JSLESS, "jsless") \ - _(JSLEQ, "jsleq") \ - _(JSGRTR, "jsgrtr") \ - _(JSGEQ, "jsgeq") \ - _(SHL, "shl") \ - _(SHR, "shr") \ - _(SSHR, "sshr") \ - _(SHL_C_PRI, "shl.c.pri") \ - _(SHL_C_ALT, "shl.c.alt") \ - _(SHR_C_PRI, "shr.c.pri") \ - _(SHR_C_ALT, "shr.c.alt") \ - _(SMUL, "smul") \ - _(SDIV, "sdiv") \ - _(SDIV_ALT, "sdiv.alt") \ - _(UNGEN_UMUL, "umul") \ - _(UNGEN_UDIV, "udiv") \ - _(UNGEN_UDIV_ALT, "udiv.alt") \ - _(ADD, "add") \ - _(SUB, "sub") \ - _(SUB_ALT, "sub.alt") \ - _(AND, "and") \ - _(OR, "or") \ - _(XOR, "xor") \ - _(NOT, "not") \ - _(NEG, "neg") \ - _(INVERT, "invert") \ - _(ADD_C, "add.c") \ - _(SMUL_C, "smul.c") \ - _(ZERO_PRI, "zero.pri") \ - _(ZERO_ALT, "zero.alt") \ - _(ZERO, "zero") \ - _(ZERO_S, "zero.s") \ - _(UNGEN_SIGN_PRI, "sign.pri") \ - _(UNGEN_SIGN_ALT, "sign.alt") \ - _(EQ, "eq") \ - _(NEQ, "neq") \ - _(UNGEN_LESS, "less") \ - _(UNGEN_LEQ, "leq") \ - _(UNGEN_GRTR, "grtr") \ - _(UNGEN_GEQ, "geq") \ - _(SLESS, "sless") \ - _(SLEQ, "sleq") \ - _(SGRTR, "sgrtr") \ - _(SGEQ, "sgeq") \ - _(EQ_C_PRI, "eq.c.pri") \ - _(EQ_C_ALT, "eq.c.alt") \ - _(INC_PRI, "inc.pri") \ - _(INC_ALT, "inc.alt") \ - _(INC, "inc") \ - _(INC_S, "inc.s") \ - _(INC_I, "inc.i") \ - _(DEC_PRI, "dec.pri") \ - _(DEC_ALT, "dec.alt") \ - _(DEC, "dec") \ - _(DEC_S, "dec.s") \ - _(DEC_I, "dec.i") \ - _(MOVS, "movs") \ - _(UNGEN_CMPS, "cmps") \ - _(FILL, "fill") \ - _(HALT, "halt") \ - _(BOUNDS, "bounds") \ - _(UNGEN_SYSREQ_PRI,"sysreq.pri") \ - _(SYSREQ_C, "sysreq.c") \ - _(UNGEN_FILE, "file") \ - _(UNGEN_LINE, "line") \ - _(UNGEN_SYMBOL, "symbol") \ - _(UNGEN_SRANGE, "srange") \ - _(UNGEN_JUMP_PRI, "jump.pri") \ - _(SWITCH, "switch") \ - _(CASETBL, "casetbl") \ - _(SWAP_PRI, "swap.pri") \ - _(SWAP_ALT, "swap.alt") \ - _(PUSH_ADR, "push.adr") \ - _(NOP, "nop") \ - _(SYSREQ_N, "sysreq.n") \ - _(UNGEN_SYMTAG, "symtag") \ - _(BREAK, "break") \ - _(PUSH2_C, "push2.c") \ - _(PUSH2, "push2") \ - _(PUSH2_S, "push2.s") \ - _(PUSH2_ADR, "push2.adr") \ - _(PUSH3_C, "push3.c") \ - _(PUSH3, "push3") \ - _(PUSH3_S, "push3.s") \ - _(PUSH3_ADR, "push3.adr") \ - _(PUSH4_C, "push4.c") \ - _(PUSH4, "push4") \ - _(PUSH4_S, "push4.s") \ - _(PUSH4_ADR, "push4.adr") \ - _(PUSH5_C, "push5.c") \ - _(PUSH5, "push5") \ - _(PUSH5_S, "push5.s") \ - _(PUSH5_ADR, "push5.adr") \ - _(LOAD_BOTH, "load.both") \ - _(LOAD_S_BOTH, "load.s.both") \ - _(CONST, "const") \ - _(CONST_S, "const.s") \ - _(UNGEN_SYSREQ_D, "sysreq.d") \ - _(UNGEB_SYSREQ_ND,"sysreq.nd") \ - _(TRACKER_PUSH_C, "trk.push.c") \ - _(TRACKER_POP_SETHEAP,"trk.pop") \ - _(GENARRAY, "genarray") \ - _(GENARRAY_Z, "genarray.z") \ - _(STRADJUST_PRI, "stradjust.pri") \ - _(UNGEN_STKADJUST,"stackadjust") \ - _(ENDPROC, "endproc") \ - _(FABS, "fabs") \ - _(FLOAT, "float") \ - _(FLOATADD, "float.add") \ - _(FLOATSUB, "float.sub") \ - _(FLOATMUL, "float.mul") \ - _(FLOATDIV, "float.div") \ - _(RND_TO_NEAREST, "round") \ - _(RND_TO_FLOOR, "floor") \ - _(RND_TO_CEIL, "ceil") \ - _(RND_TO_ZERO, "rndtozero") \ - _(FLOATCMP, "float.cmp") \ - _(FLOAT_GT, "float.gt") \ - _(FLOAT_GE, "float.ge") \ - _(FLOAT_LT, "float.lt") \ - _(FLOAT_LE, "float.le") \ - _(FLOAT_NE, "float.ne") \ - _(FLOAT_EQ, "float.eq") \ - _(FLOAT_NOT, "float.not") - -enum OPCODE { -#define _(op, text) OP_##op, - OPCODE_LIST(_) -#undef _ - OPCODES_TOTAL -}; - -} // namespace sp - -#endif // _INCLUDE_SPFILE_HEADERS_v1_opcodes_H diff --git a/sourcepawn/include/smx/smx-v1.h b/sourcepawn/include/smx/smx-v1.h deleted file mode 100644 index 7ea2392e..00000000 --- a/sourcepawn/include/smx/smx-v1.h +++ /dev/null @@ -1,209 +0,0 @@ -// vim: set sts=2 ts=8 sw=2 tw=99 et: -// ============================================================================= -// SourcePawn -// Copyright (C) 2004-2014 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 . -// -// 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 . - -#ifndef _INCLUDE_SPFILE_HEADERS_v1_H -#define _INCLUDE_SPFILE_HEADERS_v1_H - -#include -#include -#include - -namespace sp { - -// These structures are byte-packed. -#if defined __GNUC__ -# pragma pack(1) -#else -# pragma pack(push) -# pragma pack(1) -#endif - -// (Obsolete) debug-information is present. -static const uint16_t CODEFLAG_DEBUG = 0x1; - -// The ".data" section. -typedef struct sp_file_data_s -{ - uint32_t datasize; /**< Size of data section in memory */ - uint32_t memsize; /**< Total mem required (includes data) */ - uint32_t data; /**< File offset to data (helper) */ -} sp_file_data_t; - -// The ".publics" section. -typedef struct sp_file_publics_s -{ - uint32_t address; /**< Address relative to code section */ - uint32_t name; /**< Index into nametable */ -} sp_file_publics_t; - -// The ".natives" section. -typedef struct sp_file_natives_s -{ - uint32_t name; /**< Index into nametable */ -} sp_file_natives_t; - -// The ".pubvars" section. -typedef struct sp_file_pubvars_s -{ - uint32_t address; /**< Address relative to the DAT section */ - uint32_t name; /**< Index into nametable */ -} sp_file_pubvars_t; - -// The ".tags" section. -typedef struct sp_file_tag_s -{ - uint32_t tag_id; /**< Tag ID from compiler */ - uint32_t name; /**< Index into nametable */ -} sp_file_tag_t; - -// The ".dbg.info" section. -typedef struct sp_fdbg_info_s -{ - uint32_t num_files; /**< number of files */ - uint32_t num_lines; /**< number of lines */ - uint32_t num_syms; /**< number of symbols */ - uint32_t num_arrays; /**< number of symbols which are arrays */ -} sp_fdbg_info_t; - -// The ".dbg.files" section. -typedef struct sp_fdbg_file_s -{ - uint32_t addr; /**< Address into code */ - uint32_t name; /**< Offset into debug nametable */ -} sp_fdbg_file_t; - -// The ".dbg.lines" section. -typedef struct sp_fdbg_line_s -{ - uint32_t addr; /**< Address into code */ - uint32_t line; /**< Line number */ -} sp_fdbg_line_t; - -static const uint8_t IDENT_VARIABLE = 1; // Scalar local variable. -static const uint8_t IDENT_REFERENCE = 2; // Reference to a scalar argument. -static const uint8_t IDENT_ARRAY = 3; // Array with known dimensions. -static const uint8_t IDENT_REFARRAY = 4; // Array with unknown dimensions. -static const uint8_t IDENT_FUNCTION = 9; // Symbolic function. -static const uint8_t IDENT_VARARGS = 11; // Variadic argument (...). - -// The ".dbg.symbols" table. -typedef struct sp_fdbg_symbol_s -{ - int32_t addr; /**< Address rel to DAT or stack frame */ - int16_t tagid; /**< Tag id */ - uint32_t codestart; /**< Start scope validity in code */ - uint32_t codeend; /**< End scope validity in code */ - uint8_t ident; /**< Variable type */ - uint8_t vclass; /**< Scope class (local vs global) */ - uint16_t dimcount; /**< Dimension count (for arrays) */ - uint32_t name; /**< Offset into debug nametable */ -} sp_fdbg_symbol_t; - -// Occurs after an fdbg_symbol entry, for each dimension. -typedef struct sp_fdbg_arraydim_s -{ - int16_t tagid; /**< Tag id */ - uint32_t size; /**< Size of dimension */ -} sp_fdbg_arraydim_t; - -// Typedef for the ".names" section. -typedef char * sp_file_nametab_t; - -// Header for the ".dbg.natives" section. It is followed by a number of -// sp_fdbg_native_t entries. -typedef struct sp_fdbg_ntvtab_s -{ - uint32_t num_entries; /**< Number of entries. */ -} sp_fdbg_ntvtab_t; - -// An entry in the .dbg.natives section. Each is followed by an -// sp_fdbg_ntvarg_t for each argument. -typedef struct sp_fdbg_native_s -{ - uint32_t index; /**< Native index in the plugin. */ - uint32_t name; /**< Offset into debug nametable. */ - int16_t tagid; /**< Return tag. */ - uint16_t nargs; /**< Number of formal arguments. */ -} sp_fdbg_native_t; - -static const uint8_t IDENT_NATIVE_VARARGS = 1; - -// Each entry is followed by an sp_fdbg_arraydim_t for each dimcount. -typedef struct sp_fdbg_ntvarg_s -{ - uint8_t ident; /**< Variable type */ - int16_t tagid; /**< Tag id */ - uint16_t dimcount; /**< Dimension count (for arrays) */ - uint32_t name; /**< Offset into debug nametable */ -} sp_fdbg_ntvarg_t; - -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// DO NOT DEFINE NEW STRUCTURES BELOW. -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -#if defined __GNUC__ -# pragma pack() /* reset default packing */ -#else -# pragma pack(pop) /* reset previous packing */ -#endif - -// The packing for files changed by accident for a small window of time, and -// some files may have unparsable debug information using sp_fdbg_arraydim_t or -// sp_fdbg_symbol_t. -// -// If the file version is >= 0x0102, all structures will be packed. If the -// file version is < 0x0101, and the ".dbg.natives" table is present, -// all structures will be packed. -// -// If the version is 0x0101 and ".dbg.natives" is not present, then you must -// use the unpacked versions of those structures below. There is an extremely -// small chance, if the plugin used no natives, that the packing is -// indeterminate. This case is unlikely to be interesting, but if such a file -// exists, the only solution is to re-parse if the data looks corrupt. - -typedef struct sp_u_fdbg_arraydim_s -{ - int16_t tagid; /**< Tag id */ - uint32_t size; /**< Size of dimension */ -} sp_u_fdbg_arraydim_t; - -typedef struct sp_u_fdbg_symbol_s -{ - int32_t addr; /**< Address rel to DAT or stack frame */ - int16_t tagid; /**< Tag id */ - uint32_t codestart; /**< Start scope validity in code */ - uint32_t codeend; /**< End scope validity in code */ - uint8_t ident; /**< Variable type */ - uint8_t vclass; /**< Scope class (local vs global) */ - uint16_t dimcount; /**< Dimension count (for arrays) */ - uint32_t name; /**< Offset into debug nametable */ -} sp_u_fdbg_symbol_t; - -} // namespace sp - -#endif //_INCLUDE_SPFILE_HEADERS_v1_H - diff --git a/sourcepawn/jit/AMBuilder b/sourcepawn/jit/AMBuilder deleted file mode 100644 index f1c8fa69..00000000 --- a/sourcepawn/jit/AMBuilder +++ /dev/null @@ -1,59 +0,0 @@ -# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: -import os - -binary = SM.Library(builder, 'sourcepawn.jit.x86') -binary.compiler.includes += [ - os.path.join(SM.mms_root, 'core', 'sourcehook'), - os.path.join(builder.sourcePath, 'sourcepawn', 'jit'), - os.path.join(builder.sourcePath, 'sourcepawn', 'jit', 'x86'), - os.path.join(builder.sourcePath, 'public'), - os.path.join(builder.sourcePath, 'public', 'sourcepawn'), - os.path.join(builder.sourcePath, 'public', 'amtl'), - os.path.join(builder.sourcePath, 'public', 'jit'), - os.path.join(builder.sourcePath, 'public', 'jit', 'x86'), - os.path.join(builder.sourcePath, 'knight', 'shared'), - - # The include path for SP v2 stuff. - os.path.join(builder.sourcePath, 'sourcepawn', 'include'), -] - -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': - binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': - binary.compiler.cxxflags += ['/GR-'] - -if builder.target_platform == 'linux': - binary.compiler.postlink += ['-lpthread', '-lrt'] - -if binary.compiler.cc.behavior == 'msvc': - binary.compiler.cxxflags.remove('/TP') - -binary.sources += [ - 'BaseRuntime.cpp', - 'engine2.cpp', - 'dll_exports.cpp', - 'jit_function.cpp', - 'sp_vm_basecontext.cpp', - 'sp_vm_engine.cpp', - 'sp_vm_function.cpp', - 'opcodes.cpp', - 'interpreter.cpp', - 'watchdog_timer.cpp', - 'x86/jit_x86.cpp', - 'zlib/adler32.c', - 'zlib/compress.c', - 'zlib/crc32.c', - 'zlib/deflate.c', - 'zlib/gzio.c', - 'zlib/infback.c', - 'zlib/inffast.c', - 'zlib/inflate.c', - 'zlib/inftrees.c', - 'zlib/trees.c', - 'zlib/uncompr.c', - 'zlib/zutil.c', - 'md5/md5.cpp', - '../../knight/shared/KeCodeAllocator.cpp', - '../../public/jit/x86/assembler-x86.cpp', -] -SM.binaries += [builder.Add(binary)] diff --git a/sourcepawn/jit/BaseRuntime.cpp b/sourcepawn/jit/BaseRuntime.cpp deleted file mode 100644 index 2fade850..00000000 --- a/sourcepawn/jit/BaseRuntime.cpp +++ /dev/null @@ -1,605 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -#include -#include -#include -#include -#include "BaseRuntime.h" -#include "sp_vm_engine.h" -#include "x86/jit_x86.h" -#include "sp_vm_basecontext.h" -#include "engine2.h" - -#include "md5/md5.h" - -using namespace sp; -using namespace SourcePawn; - -static inline bool -IsPointerCellAligned(void *p) -{ - return uintptr_t(p) % 4 == 0; -} - -BaseRuntime::BaseRuntime() - : m_Debug(&m_plugin), - m_pCtx(NULL), - m_PubFuncs(NULL), - m_PubJitFuncs(NULL), - co_(NULL), - m_CompSerial(0) -{ - memset(&m_plugin, 0, sizeof(m_plugin)); - - m_MaxFuncs = 0; - m_NumFuncs = 0; - float_table_ = NULL; - function_map_ = NULL; - alt_pcode_ = NULL; - - memset(m_CodeHash, 0, sizeof(m_CodeHash)); - memset(m_DataHash, 0, sizeof(m_DataHash)); - - ke::AutoLock lock(g_Jit.Mutex()); - g_Jit.RegisterRuntime(this); -} - -BaseRuntime::~BaseRuntime() -{ - // The watchdog thread takes the global JIT lock while it patches all - // runtimes. It is not enough to ensure that the unlinking of the runtime is - // protected; we cannot delete functions or code while the watchdog might be - // executing. Therefore, the entire destructor is guarded. - ke::AutoLock lock(g_Jit.Mutex()); - - g_Jit.DeregisterRuntime(this); - - for (uint32_t i = 0; i < m_plugin.num_publics; i++) - delete m_PubFuncs[i]; - delete [] m_PubFuncs; - delete [] m_PubJitFuncs; - delete [] float_table_; - delete [] function_map_; - delete [] alt_pcode_; - - for (size_t i = 0; i < m_JitFunctions.length(); i++) - delete m_JitFunctions[i]; - - delete m_pCtx; - if (co_) - co_->Abort(); - - free(m_plugin.base); - delete [] m_plugin.memory; - delete [] m_plugin.publics; - delete [] m_plugin.pubvars; - delete [] m_plugin.natives; - free(m_plugin.name); -} - -struct NativeMapping { - const char *name; - unsigned opcode; -}; - -static const NativeMapping sNativeMap[] = { - { "FloatAbs", OP_FABS }, - { "FloatAdd", OP_FLOATADD }, - { "FloatSub", OP_FLOATSUB }, - { "FloatMul", OP_FLOATMUL }, - { "FloatDiv", OP_FLOATDIV }, - { "float", OP_FLOAT }, - { "FloatCompare", OP_FLOATCMP }, - { "RoundToCeil", OP_RND_TO_CEIL }, - { "RoundToZero", OP_RND_TO_ZERO }, - { "RoundToFloor", OP_RND_TO_FLOOR }, - { "RoundToNearest", OP_RND_TO_NEAREST }, - { "__FLOAT_GT__", OP_FLOAT_GT }, - { "__FLOAT_GE__", OP_FLOAT_GE }, - { "__FLOAT_LT__", OP_FLOAT_LT }, - { "__FLOAT_LE__", OP_FLOAT_LE }, - { "__FLOAT_EQ__", OP_FLOAT_EQ }, - { "__FLOAT_NE__", OP_FLOAT_NE }, - { "__FLOAT_NOT__", OP_FLOAT_NOT }, - { NULL, 0 }, -}; - -void -BaseRuntime::SetupFloatNativeRemapping() -{ - float_table_ = new floattbl_t[m_plugin.num_natives]; - for (size_t i = 0; i < m_plugin.num_natives; i++) { - const char *name = m_plugin.natives[i].name; - const NativeMapping *iter = sNativeMap; - while (iter->name) { - if (strcmp(name, iter->name) == 0) { - float_table_[i].found = true; - float_table_[i].index = iter->opcode; - break; - } - iter++; - } - } -} - -unsigned -BaseRuntime::GetNativeReplacement(size_t index) -{ - if (!float_table_[index].found) - return OP_NOP; - return float_table_[index].index; -} - -void -BaseRuntime::SetName(const char *name) -{ - m_plugin.name = strdup(name); -} - -static cell_t InvalidNative(IPluginContext *pCtx, const cell_t *params) -{ - return pCtx->ThrowNativeErrorEx(SP_ERROR_INVALID_NATIVE, "Invalid native"); -} - -int BaseRuntime::CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base) -{ - char *nameptr; - uint8_t sectnum = 0; - sp_file_section_t *secptr = (sp_file_section_t *)(base + sizeof(sp_file_hdr_t)); - - memset(&m_plugin, 0, sizeof(m_plugin)); - - m_plugin.base = base; - m_plugin.base_size = hdr->imagesize; - - if (hdr->version == 0x0101) - m_plugin.debug.unpacked = true; - - /* We have to read the name section first */ - for (sectnum = 0; sectnum < hdr->sections; sectnum++) { - nameptr = (char *)(base + hdr->stringtab + secptr[sectnum].nameoffs); - if (strcmp(nameptr, ".names") == 0) { - m_plugin.stringbase = (const char *)(base + secptr[sectnum].dataoffs); - break; - } - } - - sectnum = 0; - - /* Now read the rest of the sections */ - while (sectnum < hdr->sections) { - nameptr = (char *)(base + hdr->stringtab + secptr->nameoffs); - - if (!(m_plugin.pcode) && !strcmp(nameptr, ".code")) { - sp_file_code_t *cod = (sp_file_code_t *)(base + secptr->dataoffs); - - if (cod->codeversion < SmxConsts::CODE_VERSION_SP1_MIN) - return SP_ERROR_CODE_TOO_OLD; - if (cod->codeversion > SmxConsts::CODE_VERSION_SP1_MAX) - return SP_ERROR_CODE_TOO_NEW; - - m_plugin.pcode = base + secptr->dataoffs + cod->code; - m_plugin.pcode_size = cod->codesize; - m_plugin.flags = cod->flags; - m_plugin.pcode_version = cod->codeversion; - if (!IsPointerCellAligned(m_plugin.pcode)) { - // The JIT requires that pcode is cell-aligned, so if it's not, we - // remap the code segment to a new address. - alt_pcode_ = new uint8_t[m_plugin.pcode_size]; - memcpy(alt_pcode_, m_plugin.pcode, m_plugin.pcode_size); - assert(IsPointerCellAligned(alt_pcode_)); - - m_plugin.pcode = alt_pcode_; - } - } else if (!(m_plugin.data) && !strcmp(nameptr, ".data")) { - sp_file_data_t *dat = (sp_file_data_t *)(base + secptr->dataoffs); - m_plugin.data = base + secptr->dataoffs + dat->data; - m_plugin.data_size = dat->datasize; - m_plugin.mem_size = dat->memsize; - m_plugin.memory = new uint8_t[m_plugin.mem_size]; - memcpy(m_plugin.memory, m_plugin.data, m_plugin.data_size); - } else if ((m_plugin.publics == NULL) && !strcmp(nameptr, ".publics")) { - sp_file_publics_t *publics; - - publics = (sp_file_publics_t *)(base + secptr->dataoffs); - m_plugin.num_publics = secptr->size / sizeof(sp_file_publics_t); - - if (m_plugin.num_publics > 0) { - m_plugin.publics = new sp_public_t[m_plugin.num_publics]; - - for (uint32_t i = 0; i < m_plugin.num_publics; i++) { - m_plugin.publics[i].code_offs = publics[i].address; - m_plugin.publics[i].funcid = (i << 1) | 1; - m_plugin.publics[i].name = m_plugin.stringbase + publics[i].name; - } - } - } else if ((m_plugin.pubvars == NULL) && !strcmp(nameptr, ".pubvars")) { - sp_file_pubvars_t *pubvars; - - pubvars = (sp_file_pubvars_t *)(base + secptr->dataoffs); - m_plugin.num_pubvars = secptr->size / sizeof(sp_file_pubvars_t); - - if (m_plugin.num_pubvars > 0) { - m_plugin.pubvars = new sp_pubvar_t[m_plugin.num_pubvars]; - - for (uint32_t i = 0; i < m_plugin.num_pubvars; i++) { - m_plugin.pubvars[i].name = m_plugin.stringbase + pubvars[i].name; - m_plugin.pubvars[i].offs = (cell_t *)(m_plugin.memory + pubvars[i].address); - } - } - } else if ((m_plugin.natives == NULL) && !strcmp(nameptr, ".natives")) { - sp_file_natives_t *natives; - - natives = (sp_file_natives_t *)(base + secptr->dataoffs); - m_plugin.num_natives = secptr->size / sizeof(sp_file_natives_t); - - if (m_plugin.num_natives > 0) { - m_plugin.natives = new sp_native_t[m_plugin.num_natives]; - - for (uint32_t i = 0; i < m_plugin.num_natives; i++) { - m_plugin.natives[i].flags = 0; - m_plugin.natives[i].pfn = InvalidNative; - m_plugin.natives[i].status = SP_NATIVE_UNBOUND; - m_plugin.natives[i].user = NULL; - m_plugin.natives[i].name = m_plugin.stringbase + natives[i].name; - } - } - } else if (!(m_plugin.debug.files) && !strcmp(nameptr, ".dbg.files")) { - m_plugin.debug.files = (sp_fdbg_file_t *)(base + secptr->dataoffs); - } else if (!(m_plugin.debug.lines) && !strcmp(nameptr, ".dbg.lines")) { - m_plugin.debug.lines = (sp_fdbg_line_t *)(base + secptr->dataoffs); - } else if (!(m_plugin.debug.symbols) && !strcmp(nameptr, ".dbg.symbols")) { - m_plugin.debug.symbols = (sp_fdbg_symbol_t *)(base + secptr->dataoffs); - } else if (!(m_plugin.debug.lines_num) && !strcmp(nameptr, ".dbg.info")) { - sp_fdbg_info_t *inf = (sp_fdbg_info_t *)(base + secptr->dataoffs); - m_plugin.debug.files_num = inf->num_files; - m_plugin.debug.lines_num = inf->num_lines; - m_plugin.debug.syms_num = inf->num_syms; - } else if (!(m_plugin.debug.stringbase) && !strcmp(nameptr, ".dbg.strings")) { - m_plugin.debug.stringbase = (const char *)(base + secptr->dataoffs); - } else if (strcmp(nameptr, ".dbg.natives") == 0) { - m_plugin.debug.unpacked = false; - } - - secptr++; - sectnum++; - } - - if (m_plugin.pcode == NULL || m_plugin.data == NULL) - return SP_ERROR_FILE_FORMAT; - - if ((m_plugin.flags & sp::CODEFLAG_DEBUG) && ( - !(m_plugin.debug.files) || - !(m_plugin.debug.lines) || - !(m_plugin.debug.symbols) || - !(m_plugin.debug.stringbase) )) - { - return SP_ERROR_FILE_FORMAT; - } - - if (m_plugin.num_publics > 0) { - m_PubFuncs = new CFunction *[m_plugin.num_publics]; - memset(m_PubFuncs, 0, sizeof(CFunction *) * m_plugin.num_publics); - m_PubJitFuncs = new JitFunction *[m_plugin.num_publics]; - memset(m_PubJitFuncs, 0, sizeof(JitFunction *) * m_plugin.num_publics); - } - - MD5 md5_pcode; - md5_pcode.update(m_plugin.pcode, m_plugin.pcode_size); - md5_pcode.finalize(); - md5_pcode.raw_digest(m_CodeHash); - - MD5 md5_data; - md5_data.update(m_plugin.data, m_plugin.data_size); - md5_data.finalize(); - md5_data.raw_digest(m_DataHash); - - m_pCtx = new BaseContext(this); - co_ = g_Jit.StartCompilation(this); - - SetupFloatNativeRemapping(); - function_map_size_ = m_plugin.pcode_size / sizeof(cell_t) + 1; - function_map_ = new JitFunction *[function_map_size_]; - memset(function_map_, 0, function_map_size_ * sizeof(JitFunction *)); - - return SP_ERROR_NONE; -} - -void -BaseRuntime::AddJittedFunction(JitFunction *fn) -{ - m_JitFunctions.append(fn); - - cell_t pcode_offset = fn->GetPCodeAddress(); - assert(pcode_offset % 4 == 0); - - uint32_t pcode_index = pcode_offset / 4; - assert(pcode_index < function_map_size_); - - function_map_[pcode_index] = fn; -} - -JitFunction * -BaseRuntime::GetJittedFunctionByOffset(cell_t pcode_offset) -{ - assert(pcode_offset % 4 == 0); - - uint32_t pcode_index = pcode_offset / 4; - assert(pcode_index < function_map_size_); - - return function_map_[pcode_index]; -} - -int -BaseRuntime::FindNativeByName(const char *name, uint32_t *index) -{ - for (uint32_t i=0; i= m_plugin.num_natives) - return SP_ERROR_INDEX; - - if (native) - *native = &(m_plugin.natives[index]); - - return SP_ERROR_NONE; -} - -sp_native_t * -BaseRuntime::GetNativeByIndex(uint32_t index) -{ - assert(index < m_plugin.num_natives); - return &m_plugin.natives[index]; -} - -uint32_t -BaseRuntime::GetNativesNum() -{ - return m_plugin.num_natives; -} - -int -BaseRuntime::FindPublicByName(const char *name, uint32_t *index) -{ - int diff, high, low; - uint32_t mid; - - high = m_plugin.num_publics - 1; - low = 0; - - while (low <= high) { - mid = (low + high) / 2; - diff = strcmp(m_plugin.publics[mid].name, name); - if (diff == 0) { - if (index) - *index = mid; - return SP_ERROR_NONE; - } else if (diff < 0) { - low = mid + 1; - } else { - high = mid - 1; - } - } - - return SP_ERROR_NOT_FOUND; -} - -int -BaseRuntime::GetPublicByIndex(uint32_t index, sp_public_t **pblic) -{ - if (index >= m_plugin.num_publics) - return SP_ERROR_INDEX; - - if (pblic) - *pblic = &(m_plugin.publics[index]); - - return SP_ERROR_NONE; -} - -uint32_t -BaseRuntime::GetPublicsNum() -{ - return m_plugin.num_publics; -} - -int -BaseRuntime::GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar) -{ - if (index >= m_plugin.num_pubvars) - return SP_ERROR_INDEX; - - if (pubvar) - *pubvar = &(m_plugin.pubvars[index]); - - return SP_ERROR_NONE; -} - -int -BaseRuntime::FindPubvarByName(const char *name, uint32_t *index) -{ - int diff, high, low; - uint32_t mid; - - high = m_plugin.num_pubvars - 1; - low = 0; - - while (low <= high) { - mid = (low + high) / 2; - diff = strcmp(m_plugin.pubvars[mid].name, name); - if (diff == 0) { - if (index) - *index = mid; - return SP_ERROR_NONE; - } else if (diff < 0) { - low = mid + 1; - } else { - high = mid - 1; - } - } - - return SP_ERROR_NOT_FOUND; -} - -int -BaseRuntime::GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr) -{ - if (index >= m_plugin.num_pubvars) - return SP_ERROR_INDEX; - - *local_addr = (uint8_t *)m_plugin.pubvars[index].offs - m_plugin.memory; - *phys_addr = m_plugin.pubvars[index].offs; - - return SP_ERROR_NONE; -} - -uint32_t -BaseRuntime::GetPubVarsNum() -{ - return m_plugin.num_pubvars; -} - -IPluginContext * -BaseRuntime::GetDefaultContext() -{ - return m_pCtx; -} - -IPluginDebugInfo * -BaseRuntime::GetDebugInfo() -{ - return &m_Debug; -} - -IPluginFunction * -BaseRuntime::GetFunctionById(funcid_t func_id) -{ - CFunction *pFunc = NULL; - - if (func_id & 1) { - func_id >>= 1; - if (func_id >= m_plugin.num_publics) - return NULL; - pFunc = m_PubFuncs[func_id]; - if (!pFunc) { - m_PubFuncs[func_id] = new CFunction(this, (func_id << 1) | 1, func_id); - pFunc = m_PubFuncs[func_id]; - } - } - - return pFunc; -} - -CFunction * -BaseRuntime::GetPublicFunction(size_t index) -{ - CFunction *pFunc = m_PubFuncs[index]; - if (!pFunc) { - sp_public_t *pub = NULL; - GetPublicByIndex(index, &pub); - if (pub) - m_PubFuncs[index] = new CFunction(this, (index << 1) | 1, index); - pFunc = m_PubFuncs[index]; - } - - return pFunc; -} - -IPluginFunction * -BaseRuntime::GetFunctionByName(const char *public_name) -{ - uint32_t index; - - if (FindPublicByName(public_name, &index) != SP_ERROR_NONE) - return NULL; - - return GetPublicFunction(index); -} - -bool BaseRuntime::IsDebugging() -{ - return true; -} - -void BaseRuntime::SetPauseState(bool paused) -{ - if (paused) - { - m_plugin.run_flags |= SPFLAG_PLUGIN_PAUSED; - } - else - { - m_plugin.run_flags &= ~SPFLAG_PLUGIN_PAUSED; - } -} - -bool BaseRuntime::IsPaused() -{ - return ((m_plugin.run_flags & SPFLAG_PLUGIN_PAUSED) == SPFLAG_PLUGIN_PAUSED); -} - -size_t BaseRuntime::GetMemUsage() -{ - size_t mem = 0; - - mem += sizeof(this); - mem += sizeof(sp_plugin_t); - mem += sizeof(BaseContext); - mem += m_plugin.base_size; - - return mem; -} - -unsigned char *BaseRuntime::GetCodeHash() -{ - return m_CodeHash; -} - -unsigned char *BaseRuntime::GetDataHash() -{ - return m_DataHash; -} - -BaseContext *BaseRuntime::GetBaseContext() -{ - return m_pCtx; -} - -int -BaseRuntime::ApplyCompilationOptions(ICompilation *co) -{ - if (co == NULL) - return SP_ERROR_NONE; - - co_ = g_Jit.ApplyOptions(co_, co); - m_plugin.prof_flags = ((CompData *)co_)->profile; - - return SP_ERROR_NONE; -} - -int -BaseRuntime::CreateBlank(uint32_t heastk) -{ - memset(&m_plugin, 0, sizeof(m_plugin)); - - /* Align to cell_t bytes */ - heastk += sizeof(cell_t); - heastk -= heastk % sizeof(cell_t); - - m_plugin.mem_size = heastk; - m_plugin.memory = new uint8_t[heastk]; - - m_pCtx = new BaseContext(this); - co_ = g_Jit.StartCompilation(this); - - return SP_ERROR_NONE; -} diff --git a/sourcepawn/jit/BaseRuntime.h b/sourcepawn/jit/BaseRuntime.h deleted file mode 100644 index 6ee331be..00000000 --- a/sourcepawn/jit/BaseRuntime.h +++ /dev/null @@ -1,118 +0,0 @@ -// vim: set ts=8 sw=2 sts=2 tw=99 et: -#ifndef _INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_ -#define _INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_ - -#include -#include -#include -#include "jit_shared.h" -#include "sp_vm_function.h" - -class BaseContext; -class JitFunction; - -class DebugInfo : public IPluginDebugInfo -{ -public: - DebugInfo(sp_plugin_t *plugin); -public: - int LookupFile(ucell_t addr, const char **filename); - int LookupFunction(ucell_t addr, const char **name); - int LookupLine(ucell_t addr, uint32_t *line); -private: - sp_plugin_t *m_pPlugin; -}; - -struct floattbl_t -{ - floattbl_t() { - found = false; - index = 0; - } - bool found; - unsigned int index; -}; - -/* Jit wants fast access to this so we expose things as public */ -class BaseRuntime - : public SourcePawn::IPluginRuntime, - public ke::InlineListNode -{ - public: - BaseRuntime(); - ~BaseRuntime(); - - public: - virtual int CreateBlank(uint32_t heastk); - virtual int CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base); - virtual bool IsDebugging(); - virtual IPluginDebugInfo *GetDebugInfo(); - virtual int FindNativeByName(const char *name, uint32_t *index); - virtual int GetNativeByIndex(uint32_t index, sp_native_t **native); - virtual sp_native_t *GetNativeByIndex(uint32_t index); - virtual uint32_t GetNativesNum(); - virtual int FindPublicByName(const char *name, uint32_t *index); - virtual int GetPublicByIndex(uint32_t index, sp_public_t **publicptr); - virtual uint32_t GetPublicsNum(); - virtual int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar); - virtual int FindPubvarByName(const char *name, uint32_t *index); - virtual int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr); - virtual uint32_t GetPubVarsNum(); - virtual IPluginFunction *GetFunctionByName(const char *public_name); - virtual IPluginFunction *GetFunctionById(funcid_t func_id); - virtual IPluginContext *GetDefaultContext(); - virtual int ApplyCompilationOptions(ICompilation *co); - virtual void SetPauseState(bool paused); - virtual bool IsPaused(); - virtual size_t GetMemUsage(); - virtual unsigned char *GetCodeHash(); - virtual unsigned char *GetDataHash(); - JitFunction *GetJittedFunctionByOffset(cell_t pcode_offset); - void AddJittedFunction(JitFunction *fn); - void SetName(const char *name); - unsigned GetNativeReplacement(size_t index); - CFunction *GetPublicFunction(size_t index); - - BaseContext *GetBaseContext(); - const sp_plugin_t *plugin() const { - return &m_plugin; - } - - size_t NumJitFunctions() const { - return m_JitFunctions.length(); - } - JitFunction *GetJitFunction(size_t i) const { - return m_JitFunctions[i]; - } - - private: - void SetupFloatNativeRemapping(); - - private: - sp_plugin_t m_plugin; - uint8_t *alt_pcode_; - unsigned int m_NumFuncs; - unsigned int m_MaxFuncs; - floattbl_t *float_table_; - JitFunction **function_map_; - size_t function_map_size_; - ke::Vector m_JitFunctions; - - public: - DebugInfo m_Debug; - BaseContext *m_pCtx; - CFunction **m_PubFuncs; - JitFunction **m_PubJitFuncs; - - private: - ICompilation *co_; - - public: - unsigned int m_CompSerial; - - unsigned char m_CodeHash[16]; - unsigned char m_DataHash[16]; -}; - -#endif //_INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_ - diff --git a/sourcepawn/jit/Makefile b/sourcepawn/jit/Makefile deleted file mode 100644 index 399dd911..00000000 --- a/sourcepawn/jit/Makefile +++ /dev/null @@ -1,118 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -MMSOURCE17 = ../../../mmsource-1.7 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = sourcepawn.jit.x86 - -OBJECTS = dll_exports.cpp \ - x86/jit_x86.cpp \ - sp_vm_basecontext.cpp \ - sp_vm_engine.cpp \ - sp_vm_function.cpp \ - engine2.cpp \ - BaseRuntime.cpp \ - opcodes.cpp \ - jit_function.cpp \ - md5/md5.cpp \ - zlib/adler32.c \ - zlib/compress.c \ - zlib/crc32.c \ - zlib/deflate.c \ - zlib/gzio.c \ - zlib/infback.c \ - zlib/inffast.c \ - zlib/inflate.c \ - zlib/inftrees.c \ - zlib/trees.c \ - zlib/uncompr.c \ - zlib/zutil.c \ - -OBJECTS += ../../knight/shared/KeCodeAllocator.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc - -LINK = -m32 -ldl -lm - -INCLUDE = -I. -I.. -I$(SMSDK)/public -I$(SMSDK)/public/jit -I$(SMSDK)/public/jit/x86 \ - -I$(SMSDK)/public/sourcepawn -I$(MMSOURCE17)/core/sourcehook -I$(SMSDK)/knight/shared -Ix86 - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -DHAVE_STDINT_H \ - -m32 -Wno-uninitialized -Werror -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -OS := $(shell uname -s) -ifeq "$(OS)" "Darwin" - LINK += -dynamiclib - BINARY = $(PROJECT).dylib -else - LINK += -static-libgcc -shared - BINARY = $(PROJECT).so -endif - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:../../knight/shared/%.cpp=$(BIN_DIR)/knight/%.o) -OBJ_LINUX := $(OBJ_LINUX:%.cpp=$(BIN_DIR)/%.o) -OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o) - -default: all - -$(BIN_DIR)/%.o: %.c - $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -$(BIN_DIR)/knight/%.o: ../../knight/shared/%.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: - mkdir -p $(BIN_DIR)/x86 - mkdir -p $(BIN_DIR)/zlib - mkdir -p $(BIN_DIR)/knight - $(MAKE) -f Makefile jit - -jit: $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f Makefile all DEBUG=true - -clean: - rm -rf $(BIN_DIR)/x86/*.o - rm -rf $(BIN_DIR)/zlib/*.o - rm -rf $(BIN_DIR)/knight/*.o - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/$(BINARY) - diff --git a/sourcepawn/jit/Makefile.shell b/sourcepawn/jit/Makefile.shell deleted file mode 100644 index 127f0aaa..00000000 --- a/sourcepawn/jit/Makefile.shell +++ /dev/null @@ -1,119 +0,0 @@ -# (C)2004-2008 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -SMSDK = ../.. -MMSOURCE17 = ../../../mmsource-1.7 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = spshell - -OBJECTS = dll_exports.cpp \ - x86/jit_x86.cpp \ - sp_vm_basecontext.cpp \ - sp_vm_engine.cpp \ - sp_vm_function.cpp \ - engine2.cpp \ - BaseRuntime.cpp \ - jit_function.cpp \ - opcodes.cpp \ - watchdog_timer.cpp \ - interpreter.cpp \ - md5/md5.cpp \ - zlib/adler32.c \ - zlib/compress.c \ - zlib/crc32.c \ - zlib/deflate.c \ - zlib/gzio.c \ - zlib/infback.c \ - zlib/inffast.c \ - zlib/inflate.c \ - zlib/inftrees.c \ - zlib/trees.c \ - zlib/uncompr.c \ - zlib/zutil.c \ - -OBJECTS += ../../knight/shared/KeCodeAllocator.cpp -OBJECTS += ../../public/jit/x86/assembler-x86.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CXX_GCC4_FLAGS = -fvisibility-inlines-hidden -CXX = c++ -CC = cc - -LINK = -m32 -lm -lpthread -lrt - -INCLUDE = -I. -I.. -I$(SMSDK)/public -I$(SMSDK)/public/jit -I$(SMSDK)/public/jit/x86 \ - -I$(SMSDK)/public/sourcepawn -I$(MMSOURCE17)/core/sourcehook -I$(SMSDK)/knight/shared -Ix86 \ - -I$(SMSDK)/public/amtl -I$(SMSDK)/sourcepawn/include - -CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -DHAVE_STDINT_H \ - -m32 -Wno-uninitialized -Werror -DSPSHELL -ggdb3 -Wno-unused -CXXFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti -Wno-delete-non-virtual-dtor - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug.shell - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release.shell - CFLAGS += $(C_OPT_FLAGS) -endif - -GCC_VERSION := $(shell $(CXX) -dumpversion >&1 | cut -b1) -ifeq "$(GCC_VERSION)" "4" - CFLAGS += $(C_GCC4_FLAGS) - CXXFLAGS += $(CXX_GCC4_FLAGS) -endif - -OBJ_LINUX := $(OBJECTS:../../knight/shared/%.cpp=$(BIN_DIR)/knight/%.o) -OBJ_LINUX := $(OBJ_LINUX:../../public/jit/x86/%.cpp=$(BIN_DIR)/%.o) -OBJ_LINUX := $(OBJ_LINUX:%.cpp=$(BIN_DIR)/%.o) -OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o) - -default: all - -$(BIN_DIR)/%.o: %.c - $(CC) $(INCLUDE) $(CFLAGS) -o $@ -c $< - -$(BIN_DIR)/%.o: %.cpp - $(CXX) $(INCLUDE) $(CFLAGS) $(CXXFLAGS) -o $@ -c $< - -$(BIN_DIR)/knight/%.o: ../../knight/shared/%.cpp - $(CXX) $(INCLUDE) $(CFLAGS) $(CXXFLAGS) -o $@ -c $< - -$(BIN_DIR)/assembler-x86.o: ../../public/jit/x86/assembler-x86.cpp - $(CXX) $(INCLUDE) $(CFLAGS) $(CXXFLAGS) -o $@ -c $< - -all: - mkdir -p $(BIN_DIR)/x86 - mkdir -p $(BIN_DIR)/md5 - mkdir -p $(BIN_DIR)/zlib - mkdir -p $(BIN_DIR)/knight - $(MAKE) -f Makefile.shell jit - -jit: $(OBJ_LINUX) - $(CXX) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(PROJECT) - -debug: - $(MAKE) -f Makefile.shell all DEBUG=true - -clean: - rm -f $(BIN_DIR)/x86/*.o -# rm -rf $(BIN_DIR)/zlib/*.o -# rm -rf $(BIN_DIR)/knight/*.o - rm -f $(BIN_DIR)/*.o - rm -f $(BIN_DIR)/$(PROJECT) - diff --git a/sourcepawn/jit/dll_exports.cpp b/sourcepawn/jit/dll_exports.cpp deleted file mode 100644 index 9a7bc354..00000000 --- a/sourcepawn/jit/dll_exports.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/** - * vim: set ts=4 sts=4 sw=4 tw=99 noet: - * ============================================================================= - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#include -#include -#include -#include "x86/jit_x86.h" -#include "dll_exports.h" -#include "sp_vm_engine.h" -#include "engine2.h" - -using namespace SourcePawn; - -SourcePawnEngine2 g_engine2; - -#ifdef SPSHELL -template class AutoT -{ -public: - AutoT(T *t) - : t_(t) - { - } - ~AutoT() - { - delete t_; - } - - operator T *() const { - return t_; - } - bool operator !() const { - return !t_; - } - T * operator ->() const { - return t_; - } -private: - T *t_; -}; - -class ShellDebugListener : public IDebugListener -{ -public: - void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error) { - int n_err = error->GetErrorCode(); - - if (n_err != SP_ERROR_NATIVE) - { - fprintf(stderr, "plugin error: %s\n", error->GetErrorString()); - } - - if (const char *lastname = error->GetLastNative(NULL)) - { - if (const char *custerr = error->GetCustomErrorString()) - { - fprintf(stderr, "Native \"%s\" reported: %s", lastname, custerr); - } else { - fprintf(stderr, "Native \"%s\" encountered a generic error.", lastname); - } - } - - if (!error->DebugInfoAvailable()) - { - fprintf(stderr, "Debug info not available!\n"); - return; - } - - CallStackInfo stk_info; - int i = 0; - fprintf(stderr, "Displaying call stack trace:\n"); - while (error->GetTraceInfo(&stk_info)) - { - fprintf(stderr, - " [%d] Line %d, %s::%s()\n", - i++, - stk_info.line, - stk_info.filename, - stk_info.function); - } - } - - void OnDebugSpew(const char *msg, ...) { -#if !defined(NDEBUG) && defined(DEBUG) - va_list ap; - va_start(ap, msg); - vfprintf(stderr, msg, ap); - va_end(ap); -#endif - } -}; - -static cell_t Print(IPluginContext *cx, const cell_t *params) -{ - char *p; - cx->LocalToString(params[1], &p); - - return printf("%s", p); -} - -static cell_t PrintNum(IPluginContext *cx, const cell_t *params) -{ - return printf("%d\n", params[1]); -} - -static cell_t PrintNums(IPluginContext *cx, const cell_t *params) -{ - for (size_t i = 1; i <= size_t(params[0]); i++) { - int err; - cell_t *addr; - if ((err = cx->LocalToPhysAddr(params[i], &addr)) != SP_ERROR_NONE) - return cx->ThrowNativeErrorEx(err, "Could not read argument"); - fprintf(stdout, "%d", *addr); - if (i != size_t(params[0])) - fprintf(stdout, ", "); - } - fprintf(stdout, "\n"); - return 1; -} - -static cell_t DoNothing(IPluginContext *cx, const cell_t *params) -{ - return 1; -} - -static void BindNative(IPluginRuntime *rt, const char *name, SPVM_NATIVE_FUNC fn) -{ - int err; - uint32_t index; - if ((err = rt->FindNativeByName(name, &index)) != SP_ERROR_NONE) - return; - - sp_native_t *native; - if (rt->GetNativeByIndex(index, &native) != SP_ERROR_NONE) - return; - - native->pfn = fn; - native->status = SP_NATIVE_BOUND; -} - -static cell_t PrintFloat(IPluginContext *cx, const cell_t *params) -{ - return printf("%f\n", sp_ctof(params[1])); -} - -static int Execute(const char *file) -{ - ICompilation *co = g_engine2.StartCompilation(); - if (!co) { - fprintf(stderr, "Could not create a compilation context\n"); - return 1; - } - - int err; - AutoT rt(g_engine2.LoadPlugin(co, file, &err)); - if (!rt) { - fprintf(stderr, "Could not load plugin: %s\n", g_engine1.GetErrorString(err)); - return 1; - } - - BindNative(rt, "print", Print); - BindNative(rt, "printnum", PrintNum); - BindNative(rt, "printnums", PrintNums); - BindNative(rt, "printfloat", PrintFloat); - BindNative(rt, "donothing", DoNothing); - - IPluginFunction *fun = rt->GetFunctionByName("main"); - if (!fun) - return 0; - - IPluginContext *cx = rt->GetDefaultContext(); - - int result = fun->Execute2(cx, &err); - if (err != SP_ERROR_NONE) { - fprintf(stderr, "Error executing main(): %s\n", g_engine1.GetErrorString(err)); - return 1; - } - - return result; -} - -int main(int argc, char **argv) -{ - if (argc != 2) { - fprintf(stderr, "Usage: \n"); - return 1; - } - - if (!g_engine2.Initialize()) { - fprintf(stderr, "Could not initialize ISourcePawnEngine2\n"); - return 1; - } - - if (getenv("DISABLE_JIT")) - g_engine2.SetJitEnabled(false); - - ShellDebugListener debug; - g_engine1.SetDebugListener(&debug); - g_engine2.InstallWatchdogTimer(5000); - - int errcode = Execute(argv[1]); - - g_engine1.SetDebugListener(NULL); - g_engine2.Shutdown(); - return errcode; -} - -#else -EXPORTFUNC ISourcePawnEngine *GetSourcePawnEngine1() -{ - return &g_engine1; -} - -EXPORTFUNC ISourcePawnEngine2 *GetSourcePawnEngine2() -{ - return &g_engine2; -} -#endif - -#if defined __linux__ || defined __APPLE__ -extern "C" void __cxa_pure_virtual(void) -{ -} - -void *operator new(size_t size) -{ - return malloc(size); -} - -void *operator new[](size_t size) -{ - return malloc(size); -} - -void operator delete(void *ptr) -{ - free(ptr); -} - -void operator delete[](void * ptr) -{ - free(ptr); -} -#endif - diff --git a/sourcepawn/jit/dll_exports.h b/sourcepawn/jit/dll_exports.h deleted file mode 100644 index 2b57676e..00000000 --- a/sourcepawn/jit/dll_exports.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEPAWN_JIT_X86_DLL_H_ -#define _INCLUDE_SOURCEPAWN_JIT_X86_DLL_H_ - -#include - -#if defined WIN32 -#define EXPORTFUNC extern "C" __declspec(dllexport) -#elif defined __GNUC__ -#if __GNUC__ >= 3 -#define EXPORTFUNC extern "C" __attribute__((visibility("default"))) -#else -#define EXPORTFUNC extern "C" -#endif //__GNUC__ >= 3 -#endif //defined __GNUC__ - -#endif //_INCLUDE_SOURCEPAWN_JIT_X86_DLL_H_ diff --git a/sourcepawn/jit/engine2.cpp b/sourcepawn/jit/engine2.cpp deleted file mode 100644 index 2c1b73f9..00000000 --- a/sourcepawn/jit/engine2.cpp +++ /dev/null @@ -1,212 +0,0 @@ -// vim: set ts=4 sw=4 tw=99 noet: -#include -#include -#include -#include "engine2.h" -#include "x86/jit_x86.h" -#include "zlib/zlib.h" -#include "BaseRuntime.h" -#include "sp_vm_engine.h" -#include "watchdog_timer.h" -#include - -using namespace SourcePawn; - -SourcePawnEngine2::SourcePawnEngine2() -{ - profiler_ = NULL; - jit_enabled_ = true; -} - -IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file, int *err) -{ - sp_file_hdr_t hdr; - uint8_t *base; - int z_result; - int error; - BaseRuntime *pRuntime; - - FILE *fp = fopen(file, "rb"); - - if (!fp) - { - error = SP_ERROR_NOT_FOUND; - goto return_error; - } - - /* Rewind for safety */ - fread(&hdr, sizeof(sp_file_hdr_t), 1, fp); - - if (hdr.magic != SmxConsts::FILE_MAGIC) - { - error = SP_ERROR_FILE_FORMAT; - goto return_error; - } - - switch (hdr.compression) - { - case SmxConsts::FILE_COMPRESSION_GZ: - { - uint32_t uncompsize = hdr.imagesize - hdr.dataoffs; - uint32_t compsize = hdr.disksize - hdr.dataoffs; - uint32_t sectsize = hdr.dataoffs - sizeof(sp_file_hdr_t); - uLongf destlen = uncompsize; - - char *tempbuf = (char *)malloc(compsize); - void *uncompdata = malloc(uncompsize); - void *sectheader = malloc(sectsize); - - fread(sectheader, sectsize, 1, fp); - fread(tempbuf, compsize, 1, fp); - - z_result = uncompress((Bytef *)uncompdata, &destlen, (Bytef *)tempbuf, compsize); - free(tempbuf); - if (z_result != Z_OK) - { - free(sectheader); - free(uncompdata); - error = SP_ERROR_DECOMPRESSOR; - goto return_error; - } - - base = (uint8_t *)malloc(hdr.imagesize); - memcpy(base, &hdr, sizeof(sp_file_hdr_t)); - memcpy(base + sizeof(sp_file_hdr_t), sectheader, sectsize); - free(sectheader); - memcpy(base + hdr.dataoffs, uncompdata, uncompsize); - free(uncompdata); - break; - } - case SmxConsts::FILE_COMPRESSION_NONE: - { - base = (uint8_t *)malloc(hdr.imagesize); - rewind(fp); - fread(base, hdr.imagesize, 1, fp); - break; - } - default: - { - error = SP_ERROR_DECOMPRESSOR; - goto return_error; - } - } - - pRuntime = new BaseRuntime(); - if ((error = pRuntime->CreateFromMemory(&hdr, base)) != SP_ERROR_NONE) - { - delete pRuntime; - goto return_error; - } - - size_t len; - - len = strlen(file); - for (size_t i = len - 1; i < len; i--) - { - if (file[i] == '/' - #if defined WIN32 - || file[i] == '\\' - #endif - ) - { - pRuntime->SetName(&file[i+1]); - break; - } - } - - if (!pRuntime->plugin()->name) - { - pRuntime->SetName(file); - } - - pRuntime->ApplyCompilationOptions(co); - - fclose(fp); - - return pRuntime; - -return_error: - *err = error; - if (fp != NULL) - { - fclose(fp); - } - - return NULL; -} - -SPVM_NATIVE_FUNC SourcePawnEngine2::CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData) -{ - return g_Jit.CreateFakeNative(callback, pData); -} - -void SourcePawnEngine2::DestroyFakeNative(SPVM_NATIVE_FUNC func) -{ - g_Jit.DestroyFakeNative(func); -} - -const char *SourcePawnEngine2::GetEngineName() -{ - return "SourcePawn 1.7, jit-x86"; -} - -const char *SourcePawnEngine2::GetVersionString() -{ - return SOURCEMOD_VERSION; -} - -IDebugListener *SourcePawnEngine2::SetDebugListener(IDebugListener *listener) -{ - return g_engine1.SetDebugListener(listener); -} - -unsigned int SourcePawnEngine2::GetAPIVersion() -{ - return SOURCEPAWN_ENGINE2_API_VERSION; -} - -ICompilation *SourcePawnEngine2::StartCompilation() -{ - return g_Jit.StartCompilation(); -} - -const char *SourcePawnEngine2::GetErrorString(int err) -{ - return g_engine1.GetErrorString(err); -} - -bool SourcePawnEngine2::Initialize() -{ - return g_Jit.InitializeJIT(); -} - -void SourcePawnEngine2::Shutdown() -{ - g_WatchdogTimer.Shutdown(); - g_Jit.ShutdownJIT(); -} - -IPluginRuntime *SourcePawnEngine2::CreateEmptyRuntime(const char *name, uint32_t memory) -{ - int err; - BaseRuntime *rt; - - rt = new BaseRuntime(); - if ((err = rt->CreateBlank(memory)) != SP_ERROR_NONE) - { - delete rt; - return NULL; - } - - rt->SetName(name != NULL ? name : ""); - - rt->ApplyCompilationOptions(NULL); - - return rt; -} - -bool SourcePawnEngine2::InstallWatchdogTimer(size_t timeout_ms) -{ - return g_WatchdogTimer.Initialize(timeout_ms); -} - diff --git a/sourcepawn/jit/engine2.h b/sourcepawn/jit/engine2.h deleted file mode 100644 index 249c24f6..00000000 --- a/sourcepawn/jit/engine2.h +++ /dev/null @@ -1,86 +0,0 @@ -// vim: set ts=4 sw=4 tw=99 noet: -#ifndef _INCLUDE_SOURCEPAWN_ENGINE_2_H_ -#define _INCLUDE_SOURCEPAWN_ENGINE_2_H_ - -#include - -namespace SourcePawn -{ - /** - * @brief Outlines the interface a Virtual Machine (JIT) must expose - */ - class SourcePawnEngine2 : public ISourcePawnEngine2 - { - public: - SourcePawnEngine2(); - public: - unsigned int GetAPIVersion(); - const char *GetEngineName(); - const char *GetVersionString(); - IPluginRuntime *LoadPlugin(ICompilation *co, const char *file, int *err); - SPVM_NATIVE_FUNC CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData); - void DestroyFakeNative(SPVM_NATIVE_FUNC func); - IDebugListener *SetDebugListener(IDebugListener *listener); - ICompilation *StartCompilation(); - const char *GetErrorString(int err); - bool Initialize(); - void Shutdown(); - IPluginRuntime *CreateEmptyRuntime(const char *name, uint32_t memory); - bool InstallWatchdogTimer(size_t timeout_ms); - - bool SetJitEnabled(bool enabled) { - jit_enabled_ = enabled; - return true; - } - - bool IsJitEnabled() { - return jit_enabled_; - } - - void SetProfiler(IProfiler *profiler) { - // Deprecated. - } - - void EnableProfiling() { - profiling_enabled_ = !!profiler_; - } - void DisableProfiling() { - profiling_enabled_ = false; - } - bool IsProfilingEnabled() { - return profiling_enabled_; - } - void SetProfilingTool(IProfilingTool *tool) { - profiler_ = tool; - } - - public: - IProfilingTool *GetProfiler() { - return profiler_; - } - private: - IProfilingTool *profiler_; - bool jit_enabled_; - bool profiling_enabled_; - }; -} - -extern SourcePawn::SourcePawnEngine2 g_engine2; - -class EnterProfileScope -{ -public: - EnterProfileScope(const char *group, const char *name) - { - if (g_engine2.IsProfilingEnabled()) - g_engine2.GetProfiler()->EnterScope(group, name); - } - - ~EnterProfileScope() - { - if (g_engine2.IsProfilingEnabled()) - g_engine2.GetProfiler()->LeaveScope(); - } -}; - -#endif //_INCLUDE_SOURCEPAWN_ENGINE_2_H_ diff --git a/sourcepawn/jit/interpreter.cpp b/sourcepawn/jit/interpreter.cpp deleted file mode 100644 index fcaafe61..00000000 --- a/sourcepawn/jit/interpreter.cpp +++ /dev/null @@ -1,989 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -// -// This file is part of SourcePawn. -// -// SourcePawn is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// SourcePawn 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 SourcePawn. If not, see . -#include -#include -#include "interpreter.h" -#include "opcodes.h" -#include "watchdog_timer.h" - -#define STACK_MARGIN 64 - -using namespace sp; -using namespace SourcePawn; - -static inline bool -IsValidOffset(uint32_t cip) -{ - return cip % 4 == 0; -} - -static inline cell_t -Read(const sp_plugin_t *plugin, cell_t offset) -{ - return *reinterpret_cast(plugin->memory + offset); -} - -static inline void -Write(const sp_plugin_t *plugin, cell_t offset, cell_t value) -{ - *reinterpret_cast(plugin->memory + offset) = value; -} - -static inline cell_t * -Jump(const sp_plugin_t *plugin, sp_context_t *ctx, cell_t target) -{ - if (!IsValidOffset(target) || uint32_t(target) >= plugin->pcode_size) { - ctx->err = SP_ERROR_INVALID_INSTRUCTION; - return NULL; - } - - return reinterpret_cast(plugin->pcode + target); -} - -static inline cell_t * -JumpTarget(const sp_plugin_t *plugin, sp_context_t *ctx, cell_t *cip, bool cond) -{ - if (!cond) - return cip + 1; - - cell_t target = *cip; - if (!IsValidOffset(target) || uint32_t(target) >= plugin->pcode_size) { - ctx->err = SP_ERROR_INVALID_INSTRUCTION; - return NULL; - } - - cell_t *next = reinterpret_cast(plugin->pcode + target); - if (next < cip && !g_WatchdogTimer.HandleInterrupt()) { - ctx->err = SP_ERROR_TIMEOUT; - return NULL; - } - - return next; -} - -static inline bool -CheckAddress(const sp_plugin_t *plugin, sp_context_t *ctx, cell_t *stk, cell_t addr) -{ - if (uint32_t(addr) >= plugin->mem_size) { - ctx->err = SP_ERROR_MEMACCESS; - return false; - } - - if (addr < ctx->hp) - return true; - - if (reinterpret_cast(plugin->memory + addr) < stk) { - ctx->err = SP_ERROR_MEMACCESS; - return false; - } - - return true; -} - -int -PopTrackerAndSetHeap(BaseRuntime *rt) -{ - sp_context_t *ctx = rt->GetBaseContext()->GetCtx(); - tracker_t *trk = ctx->tracker; - assert(trk->pCur > trk->pBase); - - trk->pCur--; - if (trk->pCur < trk->pBase) - return SP_ERROR_TRACKER_BOUNDS; - - ucell_t amt = *trk->pCur; - if (amt > (ctx->hp - rt->plugin()->data_size)) - return SP_ERROR_HEAPMIN; - - ctx->hp -= amt; - return SP_ERROR_NONE; -} - -int -PushTracker(sp_context_t *ctx, size_t amount) -{ - tracker_t *trk = ctx->tracker; - - if ((size_t)(trk->pCur - trk->pBase) >= trk->size) - return SP_ERROR_TRACKER_BOUNDS; - - if (trk->pCur + 1 - (trk->pBase + trk->size) == 0) { - size_t disp = trk->size - 1; - trk->size *= 2; - trk->pBase = (ucell_t *)realloc(trk->pBase, trk->size * sizeof(cell_t)); - - if (!trk->pBase) - return SP_ERROR_TRACKER_BOUNDS; - - trk->pCur = trk->pBase + disp; - } - - *trk->pCur++ = amount; - return SP_ERROR_NONE; -} - -cell_t -NativeCallback(sp_context_t *ctx, ucell_t native_idx, cell_t *params) -{ - cell_t save_sp = ctx->sp; - cell_t save_hp = ctx->hp; - - ctx->n_idx = native_idx; - - sp_native_t *native = &ctx->plugin->natives[native_idx]; - - if (native->status == SP_NATIVE_UNBOUND) { - ctx->n_err = SP_ERROR_INVALID_NATIVE; - return 0; - } - - cell_t result = native->pfn(ctx->basecx, params); - - if (ctx->n_err != SP_ERROR_NONE) - return result; - - if (save_sp != ctx->sp) { - ctx->n_err = SP_ERROR_STACKLEAK; - return result; - } - if (save_hp != ctx->hp) { - ctx->n_err = SP_ERROR_HEAPLEAK; - return result; - } - - return result; -} - -cell_t -BoundNativeCallback(sp_context_t *ctx, SPVM_NATIVE_FUNC pfn, cell_t *params) -{ - cell_t save_sp = ctx->sp; - cell_t save_hp = ctx->hp; - - cell_t result = pfn(ctx->basecx, params); - - if (ctx->n_err != SP_ERROR_NONE) - return result; - - if (save_sp != ctx->sp) { - ctx->n_err = SP_ERROR_STACKLEAK; - return result; - } - if (save_hp != ctx->hp) { - ctx->n_err = SP_ERROR_HEAPLEAK; - return result; - } - - return result; -} - -static inline bool -GenerateArray(BaseRuntime *rt, sp_context_t *ctx, cell_t dims, cell_t *stk, bool autozero) -{ - if (dims == 1) { - uint32_t size = *stk; - if (size == 0 || !ke::IsUint32MultiplySafe(size, 4)) { - ctx->err = SP_ERROR_ARRAY_TOO_BIG; - return false; - } - *stk = ctx->hp; - - uint32_t bytes = size * 4; - - ctx->hp += bytes; - if (uintptr_t(ctx->plugin->memory + ctx->hp) >= uintptr_t(stk)) { - ctx->err = SP_ERROR_HEAPLOW; - return false; - } - - if ((ctx->err = PushTracker(ctx, bytes)) != SP_ERROR_NONE) - return false; - - if (autozero) - memset(ctx->plugin->memory + ctx->hp, 0, bytes); - - return true; - } - - if ((ctx->err = GenerateFullArray(rt, dims, stk, autozero)) != SP_ERROR_NONE) - return false; - - return true; -} - -int -Interpret(BaseRuntime *rt, uint32_t aCodeStart, cell_t *rval) -{ - const sp_plugin_t *plugin = rt->plugin(); - cell_t *code = reinterpret_cast(plugin->pcode); - cell_t *codeend = reinterpret_cast(plugin->pcode + plugin->pcode_size); - - if (!IsValidOffset(aCodeStart) || aCodeStart > plugin->pcode_size) - return SP_ERROR_INVALID_INSTRUCTION; - - sp_context_t *ctx = rt->GetBaseContext()->GetCtx(); - ctx->err = SP_ERROR_NONE; - - // Save the original frm. BaseContext won't, and if we error, we won't hit - // the stack unwinding code. - cell_t orig_frm = ctx->frm; - - cell_t pri = 0; - cell_t alt = 0; - cell_t *cip = code + (aCodeStart / 4); - cell_t *stk = reinterpret_cast(plugin->memory + ctx->sp); - - for (;;) { - if (cip >= codeend) { - ctx->err = SP_ERROR_INVALID_INSTRUCTION; - goto error; - } - -#if 0 - SpewOpcode(plugin, reinterpret_cast(plugin->pcode + aCodeStart), cip); -#endif - - OPCODE op = (OPCODE)*cip++; - - switch (op) { - case OP_MOVE_PRI: - pri = alt; - break; - case OP_MOVE_ALT: - alt = pri; - break; - - case OP_XCHG: - { - cell_t tmp = pri; - pri = alt; - alt = tmp; - break; - } - - case OP_ZERO: - Write(plugin, *cip++, 0); - break; - - case OP_ZERO_S: - Write(plugin, ctx->frm + *cip++, 0); - break; - - case OP_PUSH_PRI: - *--stk = pri; - break; - case OP_PUSH_ALT: - *--stk = alt; - break; - - case OP_PUSH_C: - case OP_PUSH2_C: - case OP_PUSH3_C: - case OP_PUSH4_C: - case OP_PUSH5_C: - { - int n = 1; - if (op >= OP_PUSH2_C) - n = ((op - OP_PUSH2_C) / 4) + 2; - - int i = 1; - do { - *--stk = *cip++; - } while (i++ < n); - break; - } - - case OP_PUSH_ADR: - case OP_PUSH2_ADR: - case OP_PUSH3_ADR: - case OP_PUSH4_ADR: - case OP_PUSH5_ADR: - { - int n = 1; - if (op >= OP_PUSH2_ADR) - n = ((op - OP_PUSH2_ADR) / 4) + 2; - - int i = 1; - - do { - cell_t addr = ctx->frm + *cip++; - *--stk = addr; - } while (i++ < n); - break; - } - - case OP_PUSH_S: - case OP_PUSH2_S: - case OP_PUSH3_S: - case OP_PUSH4_S: - case OP_PUSH5_S: - { - int n = 1; - if (op >= OP_PUSH2_S) - n = ((op - OP_PUSH2_S) / 4) + 2; - - int i = 1; - do { - cell_t value = Read(plugin, ctx->frm + *cip++); - *--stk = value; - } while (i++ < n); - break; - } - - case OP_PUSH: - case OP_PUSH2: - case OP_PUSH3: - case OP_PUSH4: - case OP_PUSH5: - { - int n = 1; - if (op >= OP_PUSH2) - n = ((op - OP_PUSH2) / 4) + 2; - - int i = 1; - do { - cell_t value = Read(plugin, *cip++); - *--stk = value; - } while (i++ < n); - break; - } - - case OP_ZERO_PRI: - pri = 0; - break; - case OP_ZERO_ALT: - alt = 0; - break; - - case OP_ADD: - pri += alt; - break; - - case OP_SUB: - pri -= alt; - break; - - case OP_SUB_ALT: - pri = alt - pri; - break; - - case OP_PROC: - { - *--stk = ctx->frm; - *--stk = 0; - ctx->frm = uintptr_t(stk) - uintptr_t(plugin->memory); - break; - } - - case OP_IDXADDR_B: - pri <<= *cip++; - pri += alt; - break; - - case OP_SHL: - pri <<= alt; - break; - - case OP_SHR: - pri = unsigned(pri) >> unsigned(alt); - break; - - case OP_SSHR: - pri >>= alt; - break; - - case OP_SHL_C_PRI: - pri <<= *cip++; - break; - case OP_SHL_C_ALT: - alt <<= *cip++; - break; - - case OP_SHR_C_PRI: - pri >>= *cip++; - break; - case OP_SHR_C_ALT: - alt >>= *cip++; - break; - - case OP_SMUL: - pri *= alt; - break; - - case OP_NOT: - pri = pri ? 0 : 1; - break; - - case OP_NEG: - pri = -pri; - break; - - case OP_XOR: - pri ^= alt; - break; - - case OP_OR: - pri |= alt; - break; - - case OP_AND: - pri &= alt; - break; - - case OP_INVERT: - pri = ~pri; - break; - - case OP_ADD_C: - pri += *cip++; - break; - - case OP_SMUL_C: - pri *= *cip++; - break; - - case OP_EQ: - pri = pri == alt; - break; - - case OP_NEQ: - pri = pri != alt; - break; - - case OP_SLESS: - pri = pri < alt; - break; - - case OP_SLEQ: - pri = pri <= alt; - break; - - case OP_SGRTR: - pri = pri > alt; - break; - - case OP_SGEQ: - pri = pri >= alt; - break; - - case OP_EQ_C_PRI: - pri = pri == *cip++; - break; - case OP_EQ_C_ALT: - pri = alt == *cip++; - break; - - case OP_INC_PRI: - pri++; - break; - case OP_INC_ALT: - alt++; - break; - - case OP_INC: - { - cell_t offset = *cip++; - Write(plugin, offset, Read(plugin, offset) + 1); - break; - } - - case OP_INC_S: - { - cell_t offset = *cip++; - cell_t value = Read(plugin, ctx->frm + offset); - Write(plugin, ctx->frm + offset, value + 1); - break; - } - - case OP_INC_I: - if (!CheckAddress(plugin, ctx, stk, pri)) - goto error; - Write(plugin, pri, Read(plugin, pri) + 1); - break; - - case OP_DEC_PRI: - pri--; - break; - case OP_DEC_ALT: - alt--; - break; - - case OP_DEC: - { - cell_t offset = *cip++; - Write(plugin, offset, Read(plugin, offset) - 1); - break; - } - - case OP_DEC_S: - { - cell_t offset = *cip++; - cell_t value = Read(plugin, ctx->frm + offset); - Write(plugin, ctx->frm + offset, value - 1); - break; - } - - case OP_DEC_I: - if (!CheckAddress(plugin, ctx, stk, pri)) - goto error; - Write(plugin, pri, Read(plugin, pri) - 1); - break; - - case OP_LOAD_PRI: - pri = Read(plugin, *cip++); - break; - case OP_LOAD_ALT: - alt = Read(plugin, *cip++); - break; - - case OP_LOAD_S_PRI: - pri = Read(plugin, ctx->frm + *cip++); - break; - case OP_LOAD_S_ALT: - alt = Read(plugin, ctx->frm + *cip++); - break; - - case OP_LOAD_S_BOTH: - pri = Read(plugin, ctx->frm + *cip++); - alt = Read(plugin, ctx->frm + *cip++); - break; - - case OP_LREF_S_PRI: - { - pri = Read(plugin, ctx->frm + *cip++); - pri = Read(plugin, pri); - break; - } - - case OP_LREF_S_ALT: - { - alt = Read(plugin, ctx->frm + *cip++); - alt = Read(plugin, alt); - break; - } - - case OP_CONST_PRI: - pri = *cip++; - break; - case OP_CONST_ALT: - alt = *cip++; - break; - - case OP_ADDR_PRI: - pri = ctx->frm + *cip++; - break; - case OP_ADDR_ALT: - alt = ctx->frm + *cip++; - break; - - case OP_STOR_PRI: - Write(plugin, *cip++, pri); - break; - case OP_STOR_ALT: - Write(plugin, *cip++, alt); - break; - - case OP_STOR_S_PRI: - Write(plugin, ctx->frm + *cip++, pri); - break; - case OP_STOR_S_ALT: - Write(plugin, ctx->frm +*cip++, alt); - break; - - case OP_IDXADDR: - pri = alt + pri * 4; - break; - - case OP_SREF_S_PRI: - { - cell_t offset = *cip++; - cell_t addr = Read(plugin, ctx->frm + offset); - Write(plugin, addr, pri); - break; - } - - case OP_SREF_S_ALT: - { - cell_t offset = *cip++; - cell_t addr = Read(plugin, ctx->frm + offset); - Write(plugin, addr, alt); - break; - } - - case OP_POP_PRI: - pri = *stk++; - break; - case OP_POP_ALT: - alt = *stk++; - break; - - case OP_SWAP_PRI: - case OP_SWAP_ALT: - { - cell_t reg = (op == OP_SREF_S_PRI) ? pri : alt; - cell_t temp = *stk; - *stk = reg; - reg = temp; - break; - } - - case OP_LIDX: - pri = alt + pri * 4; - if (!CheckAddress(plugin, ctx, stk, pri)) - goto error; - pri = Read(plugin, pri); - break; - - case OP_LIDX_B: - { - cell_t val = *cip++; - pri = alt + (pri << val); - if (!CheckAddress(plugin, ctx, stk, pri)) - goto error; - pri = Read(plugin, pri); - break; - } - - case OP_CONST: - { - cell_t offset = *cip++; - cell_t value = *cip++; - Write(plugin, offset, value); - break; - } - - case OP_CONST_S: - { - cell_t offset = *cip++; - cell_t value = *cip++; - Write(plugin, ctx->frm + offset, value); - break; - } - - case OP_LOAD_I: - if (!CheckAddress(plugin, ctx, stk, pri)) - goto error; - pri = Read(plugin, pri); - break; - - case OP_STOR_I: - if (!CheckAddress(plugin, ctx, stk, alt)) - goto error; - Write(plugin, alt, pri); - break; - - case OP_SDIV: - case OP_SDIV_ALT: - { - cell_t dividend = (op == OP_SDIV) ? pri : alt; - cell_t divisor = (op == OP_SDIV) ? alt : pri; - if (divisor == 0) { - ctx->err = SP_ERROR_DIVIDE_BY_ZERO; - goto error; - } - if (dividend == INT_MIN && divisor == -1) { - ctx->err = SP_ERROR_INTEGER_OVERFLOW; - goto error; - } - pri = dividend / divisor; - alt = dividend % divisor; - break; - } - - case OP_LODB_I: - { - cell_t val = *cip++; - if (!CheckAddress(plugin, ctx, stk, pri)) - goto error; - pri = Read(plugin, pri); - if (val == 1) - pri &= 0xff; - else if (val == 2) - pri &= 0xffff; - break; - } - - case OP_STRB_I: - { - cell_t val = *cip++; - if (!CheckAddress(plugin, ctx, stk, alt)) - goto error; - if (val == 1) - *reinterpret_cast(plugin->memory + alt) = pri; - else if (val == 2) - *reinterpret_cast(plugin->memory + alt) = pri; - else if (val == 4) - *reinterpret_cast(plugin->memory + alt) = pri; - break; - } - - case OP_RETN: - { - stk++; - ctx->frm = *stk++; - stk += *stk + 1; - *rval = pri; - ctx->err = SP_ERROR_NONE; - goto done; - } - - case OP_MOVS: - { - uint8_t *src = plugin->memory + pri; - uint8_t *dest = plugin->memory + alt; - memcpy(dest, src, *cip++); - break; - } - - case OP_FILL: - { - uint8_t *dest = plugin->memory + alt; - memset(dest, pri, *cip++); - break; - } - - case OP_STRADJUST_PRI: - pri += 4; - pri >>= 2; - break; - - case OP_STACK: - { - cell_t amount = *cip++; - if (!IsValidOffset(amount)) { - ctx->err = SP_ERROR_INVALID_INSTRUCTION; - goto error; - } - - stk += amount / 4; - if (amount > 0) { - if (uintptr_t(stk) >= uintptr_t(plugin->memory + plugin->mem_size)) { - ctx->err = SP_ERROR_STACKMIN; - goto error; - } - } else { - if (uintptr_t(stk) < uintptr_t(plugin->memory + ctx->hp + STACK_MARGIN)) { - ctx->err = SP_ERROR_STACKLOW; - goto error; - } - } - break; - } - - case OP_HEAP: - { - cell_t amount = *cip++; - - alt = ctx->hp; - ctx->hp += amount; - - if (amount > 0) { - if (uintptr_t(plugin->memory + ctx->hp) > uintptr_t(stk)) { - ctx->err = SP_ERROR_HEAPLOW; - goto error; - } - } else { - if (uint32_t(ctx->hp) < plugin->data_size) { - ctx->err = SP_ERROR_HEAPMIN; - goto error; - } - } - break; - } - - case OP_JUMP: - if ((cip = JumpTarget(plugin, ctx, cip, true)) == NULL) - goto error; - break; - - case OP_JZER: - if ((cip = JumpTarget(plugin, ctx, cip, pri == 0)) == NULL) - goto error; - break; - case OP_JNZ: - if ((cip = JumpTarget(plugin, ctx, cip, pri != 0)) == NULL) - goto error; - break; - - case OP_JEQ: - if ((cip = JumpTarget(plugin, ctx, cip, pri == alt)) == NULL) - goto error; - break; - case OP_JNEQ: - if ((cip = JumpTarget(plugin, ctx, cip, pri != alt)) == NULL) - goto error; - break; - case OP_JSLESS: - if ((cip = JumpTarget(plugin, ctx, cip, pri < alt)) == NULL) - goto error; - break; - case OP_JSLEQ: - if ((cip = JumpTarget(plugin, ctx, cip, pri <= alt)) == NULL) - goto error; - break; - case OP_JSGRTR: - if ((cip = JumpTarget(plugin, ctx, cip, pri > alt)) == NULL) - goto error; - break; - case OP_JSGEQ: - if ((cip = JumpTarget(plugin, ctx, cip, pri >= alt)) == NULL) - goto error; - break; - - case OP_TRACKER_PUSH_C: - { - cell_t amount = *cip++; - int error = PushTracker(ctx, amount * 4); - if (error != SP_ERROR_NONE) { - ctx->err = error; - goto error; - } - break; - } - - case OP_TRACKER_POP_SETHEAP: - { - int error = PopTrackerAndSetHeap(rt); - if (error != SP_ERROR_NONE) { - ctx->err = error; - goto error; - } - break; - } - - case OP_BREAK: - ctx->cip = uintptr_t(cip - 1) - uintptr_t(plugin->pcode); - break; - - case OP_BOUNDS: - { - cell_t value = *cip++; - if (uint32_t(pri) > uint32_t(value)) { - ctx->err = SP_ERROR_ARRAY_BOUNDS; - goto error; - } - break; - } - - case OP_CALL: - { - cell_t offset = *cip++; - - if (!IsValidOffset(offset) || uint32_t(offset) >= plugin->pcode_size) { - ctx->err = SP_ERROR_INSTRUCTION_PARAM; - goto error; - } - - if (ctx->rp >= SP_MAX_RETURN_STACK) { - ctx->err = SP_ERROR_STACKLOW; - goto error; - } - - // For debugging. - uintptr_t rcip = uintptr_t(cip - 2) - uintptr_t(plugin->pcode); - ctx->rstk_cips[ctx->rp++] = rcip; - ctx->cip = offset; - ctx->sp = uintptr_t(stk) - uintptr_t(plugin->memory); - - int err = Interpret(rt, offset, &pri); - - stk = reinterpret_cast(plugin->memory + ctx->sp); - ctx->cip = rcip; - ctx->rp--; - - if (err != SP_ERROR_NONE) - goto error; - break; - } - - case OP_GENARRAY: - case OP_GENARRAY_Z: - { - cell_t val = *cip++; - if (!GenerateArray(rt, ctx, val, stk, op == OP_GENARRAY_Z)) - goto error; - - stk += (val - 1) * 4; - break; - } - - case OP_SYSREQ_C: - case OP_SYSREQ_N: - { - uint32_t native_index = *cip++; - - if (native_index >= plugin->num_natives) { - ctx->err = SP_ERROR_INSTRUCTION_PARAM; - goto error; - } - - uint32_t num_params; - if (op == OP_SYSREQ_N) { - num_params = *cip++; - *--stk = num_params; - } - - ctx->sp = uintptr_t(stk) - uintptr_t(plugin->memory); - pri = NativeCallback(ctx, native_index, stk); - if (ctx->n_err != SP_ERROR_NONE) { - ctx->err = ctx->n_err; - goto error; - } - - if (op == OP_SYSREQ_N) - stk += num_params + 1; - break; - } - - case OP_SWITCH: - { - cell_t offset = *cip++; - cell_t *table = reinterpret_cast(plugin->pcode + offset + sizeof(cell_t)); - - size_t ncases = *table++; - cell_t target = *table++; // default case - - for (size_t i = 0; i < ncases; i++) { - if (table[i * 2] == pri) { - target = table[i * 2 + 1]; - break; - } - } - - if ((cip = Jump(plugin, ctx, target)) == NULL) - goto error; - break; - } - - default: - { - ctx->err = SP_ERROR_INVALID_INSTRUCTION; - goto error; - } - } // switch - } - - done: - assert(orig_frm == ctx->frm); - ctx->sp = uintptr_t(stk) - uintptr_t(plugin->memory); - return ctx->err; - - error: - ctx->frm = orig_frm; - goto done; -} - diff --git a/sourcepawn/jit/interpreter.h b/sourcepawn/jit/interpreter.h deleted file mode 100644 index a755b06d..00000000 --- a/sourcepawn/jit/interpreter.h +++ /dev/null @@ -1,40 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -// -// This file is part of SourcePawn. -// -// SourcePawn is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// SourcePawn 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 SourcePawn. If not, see . -#ifndef _include_sourcepawn_interpreter_h_ -#define _include_sourcepawn_interpreter_h_ - -#include -#include -#include "BaseRuntime.h" -#include "sp_vm_basecontext.h" - -struct tracker_t -{ - size_t size; - ucell_t *pBase; - ucell_t *pCur; -}; - -int Interpret(BaseRuntime *rt, uint32_t aCodeStart, cell_t *rval); - -int GenerateFullArray(BaseRuntime *rt, uint32_t argc, cell_t *argv, int autozero); -cell_t NativeCallback(sp_context_t *ctx, ucell_t native_idx, cell_t *params); -cell_t BoundNativeCallback(sp_context_t *ctx, SPVM_NATIVE_FUNC pfn, cell_t *params); -int PopTrackerAndSetHeap(BaseRuntime *rt); -int PushTracker(sp_context_t *ctx, size_t amount); - -#endif // _include_sourcepawn_interpreter_h_ diff --git a/sourcepawn/jit/jit_function.cpp b/sourcepawn/jit/jit_function.cpp deleted file mode 100644 index ffba3124..00000000 --- a/sourcepawn/jit/jit_function.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// vim: set ts=8 ts=2 sw=2 tw=99 et: -#include "jit_function.h" -#include "sp_vm_engine.h" -#include "jit_x86.h" - -JitFunction::JitFunction(void *entry_addr, cell_t pcode_offs, LoopEdge *edges, uint32_t nedges) - : m_pEntryAddr(entry_addr), - m_PcodeOffs(pcode_offs), - edges_(edges), - nedges_(nedges) -{ -} - -JitFunction::~JitFunction() -{ - delete [] edges_; - g_Jit.FreeCode(m_pEntryAddr); -} - -void * -JitFunction::GetEntryAddress() const -{ - return m_pEntryAddr; -} - -cell_t -JitFunction::GetPCodeAddress() const -{ - return m_PcodeOffs; -} - diff --git a/sourcepawn/jit/jit_function.h b/sourcepawn/jit/jit_function.h deleted file mode 100644 index 81465425..00000000 --- a/sourcepawn/jit/jit_function.h +++ /dev/null @@ -1,38 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -#ifndef _INCLUDE_SOURCEPAWN_JIT2_FUNCTION_H_ -#define _INCLUDE_SOURCEPAWN_JIT2_FUNCTION_H_ - -#include -#include - -struct LoopEdge -{ - uint32_t offset; - int32_t disp32; -}; - -class JitFunction -{ - public: - JitFunction(void *entry_addr, cell_t pcode_offs, LoopEdge *edges, uint32_t nedges); - ~JitFunction(); - - public: - void *GetEntryAddress() const; - cell_t GetPCodeAddress() const; - uint32_t NumLoopEdges() const { - return nedges_; - } - const LoopEdge &GetLoopEdge(size_t i) const { - assert(i < nedges_); - return edges_[i]; - } - - private: - void *m_pEntryAddr; - cell_t m_PcodeOffs; - LoopEdge *edges_; - uint32_t nedges_; -}; - -#endif //_INCLUDE_SOURCEPAWN_JIT2_FUNCTION_H_ diff --git a/sourcepawn/jit/jit_shared.h b/sourcepawn/jit/jit_shared.h deleted file mode 100644 index 4e06b61e..00000000 --- a/sourcepawn/jit/jit_shared.h +++ /dev/null @@ -1,97 +0,0 @@ -// vim: set ts=4 sw=4 tw=99 noet: -#ifndef _INCLUDE_SOURCEPAWN_JIT_SHARED_H_ -#define _INCLUDE_SOURCEPAWN_JIT_SHARED_H_ - -#include -#include - -using namespace sp; -using namespace SourcePawn; - -#define SP_MAX_RETURN_STACK 1024 - -/** - * @brief Information about the plugin's debug tables. These are all present if one is present. - */ -typedef struct sp_plugin_debug_s -{ - const char *stringbase; /**< base of string table */ - uint32_t files_num; /**< number of files */ - sp_fdbg_file_t *files; /**< files table */ - uint32_t lines_num; /**< number of lines */ - sp_fdbg_line_t *lines; /**< lines table */ - uint32_t syms_num; /**< number of symbols */ - sp_fdbg_symbol_t *symbols; /**< symbol table */ - bool unpacked; /**< Whether debug structures are unpacked */ -} sp_plugin_debug_t; - -class BaseContext; - -/** - * Breaks into a debugger - * Params: - * [0] - plugin context - * [1] - frm - * [2] - cip - */ -typedef int (*SPVM_DEBUGBREAK)(BaseContext *, uint32_t, uint32_t); - -/** - * @brief The rebased memory format of a plugin. This differs from the on-disk structure - * to ensure that the format is properly read. - */ -namespace SourcePawn -{ - typedef struct sp_plugin_s - { - uint8_t *base; /**< Base of memory for this plugin. */ - uint8_t *pcode; /**< P-Code of plugin */ - uint32_t pcode_size; /**< Size of p-code */ - uint8_t *data; /**< Data/memory layout */ - uint32_t data_size; /**< Size of data */ - uint32_t mem_size; /**< Required memory space */ - uint16_t flags; /**< Code flags */ - sp_plugin_debug_t debug; /**< Debug info table */ - size_t base_size; /**< Size of the entire plugin base */ - uint8_t *memory; /**< Data chunk */ - const char *stringbase; /**< base of string table */ - sp_public_t *publics; /**< Public functions table */ - uint32_t num_publics; /**< Number of publics. */ - sp_pubvar_t *pubvars; /**< Public variables table */ - uint32_t num_pubvars; /**< Number of public variables */ - sp_native_t *natives; /**< Natives table */ - uint32_t num_natives; /**< Number of natives */ - uint32_t prof_flags; /**< Profiling flags */ - uint32_t run_flags; /**< Runtime flags */ - uint32_t pcode_version; /**< P-Code version number */ - char *name; /**< Plugin/script name */ - } sp_plugin_t; -} - -struct tracker_t; -class BaseContext; - -typedef struct sp_context_s -{ - cell_t hp; /**< Heap pointer */ - cell_t sp; /**< Stack pointer */ - cell_t frm; /**< Frame pointer */ - cell_t rval; /**< Return value from InvokeFunction() */ - int32_t cip; /**< Code pointer last error occurred in */ - int32_t err; /**< Error last set by interpreter */ - int32_t n_err; /**< Error code set by a native */ - uint32_t n_idx; /**< Current native index being executed */ - tracker_t *tracker; - sp_plugin_t *plugin; - BaseContext *basecx; - void * vm[8]; /**< VM-specific pointers */ - cell_t rp; /**< Return stack pointer */ - cell_t rstk_cips[SP_MAX_RETURN_STACK]; -} sp_context_t; - -//#define SPFLAG_PLUGIN_DEBUG (1<<0) -#define SPFLAG_PLUGIN_PAUSED (1<<1) - -#define INVALID_CIP 0xFFFFFFFF - -#endif //_INCLUDE_SOURCEPAWN_JIT_SHARED_H_ diff --git a/sourcepawn/jit/md5/md5.cpp b/sourcepawn/jit/md5/md5.cpp deleted file mode 100644 index c891c5c5..00000000 --- a/sourcepawn/jit/md5/md5.cpp +++ /dev/null @@ -1,475 +0,0 @@ -// MD5.CC - source code for the C++/object oriented translation and -// modification of MD5. - -// Translation and modification (c) 1995 by Mordechai T. Abzug - -// This translation/ modification is provided "as is," without express or -// implied warranty of any kind. - -// The translator/ modifier does not claim (1) that MD5 will do what you think -// it does; (2) that this translation/ modification is accurate; or (3) that -// this software is "merchantible." (Language for this disclaimer partially -// copied from the disclaimer below). - -/* based on: - - MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm - MDDRIVER.C - test driver for MD2, MD4 and MD5 - - - Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - - */ - -#include "md5.h" - -#include -#include - -// MD5 simple initialization method - -MD5::MD5(){ - - init(); - -} - - -// MD5 block update operation. Continues an MD5 message-digest -// operation, processing another message block, and updating the -// context. - -void MD5::update (uint1 *input, uint4 input_length) { - - uint4 input_index, buffer_index; - uint4 buffer_space; // how much space is left in buffer - - if (finalized){ // so we can't update! - /*cerr << "MD5::update: Can't update a finalized digest!" << endl;*/ - return; - } - - // Compute number of bytes mod 64 - buffer_index = (unsigned int)((count[0] >> 3) & 0x3F); - - // Update number of bits - if ( (count[0] += ((uint4) input_length << 3))<((uint4) input_length << 3) ) - count[1]++; - - count[1] += ((uint4)input_length >> 29); - - - buffer_space = 64 - buffer_index; // how much space is left in buffer - - // Transform as many times as possible. - if (input_length >= buffer_space) { // ie. we have enough to fill the buffer - // fill the rest of the buffer and transform - memcpy (buffer + buffer_index, input, buffer_space); - transform (buffer); - - // now, transform each 64-byte piece of the input, bypassing the buffer - for (input_index = buffer_space; input_index + 63 < input_length; - input_index += 64) - transform (input+input_index); - - buffer_index = 0; // so we can buffer remaining - } - else - input_index=0; // so we can buffer the whole input - - - // and here we do the buffering: - memcpy(buffer+buffer_index, input+input_index, input_length-input_index); -} - - - -// MD5 update for files. -// Like above, except that it works on files (and uses above as a primitive.) - -void MD5::update(FILE *file){ - - unsigned char buffer[1024]; - int len; - - while ((len=fread(buffer, 1, 1024, file))) - update(buffer, len); - - fclose (file); - -} - - -// MD5 finalization. Ends an MD5 message-digest operation, writing the -// the message digest and zeroizing the context. - - -void MD5::finalize (){ - - unsigned char bits[8]; - unsigned int index, padLen; - static uint1 PADDING[64]={ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - if (finalized){ - /* cerr << "MD5::finalize: Already finalized this digest!" << endl;*/ - return; - } - - // Save number of bits - encode (bits, count, 8); - - // Pad out to 56 mod 64. - index = (uint4) ((count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - update (PADDING, padLen); - - // Append length (before padding) - update (bits, 8); - - // Store state in digest - encode (digest, state, 16); - - // Zeroize sensitive information - memset (buffer, 0, sizeof(*buffer)); - - finalized=1; - -} - - - - -MD5::MD5(FILE *file){ - - init(); // must be called be all constructors - update(file); - finalize (); -} - -unsigned char *MD5::raw_digest(){ - - if (!finalized){ -/* cerr << "MD5::raw_digest: Can't get digest if you haven't "<< - "finalized the digest!" <> 8) & 0xff); - output[j+2] = (uint1) ((input[i] >> 16) & 0xff); - output[j+3] = (uint1) ((input[i] >> 24) & 0xff); - } -} - - - - -// Decodes input (unsigned char) into output (UINT4). Assumes len is -// a multiple of 4. -void MD5::decode (uint4 *output, uint1 *input, uint4 len){ - - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) | - (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24); -} - - - - - -// Note: Replace "for loop" with standard memcpy if possible. -void MD5::memcpy (uint1 *output, uint1 *input, uint4 len){ - - unsigned int i; - - for (i = 0; i < len; i++) - output[i] = input[i]; -} - - - -// Note: Replace "for loop" with standard memset if possible. -void MD5::memset (uint1 *output, uint1 value, uint4 len){ - - unsigned int i; - - for (i = 0; i < len; i++) - output[i] = value; -} - - - -// ROTATE_LEFT rotates x left n bits. - -inline unsigned int MD5::rotate_left (uint4 x, uint4 n){ - return (x << n) | (x >> (32-n)) ; -} - - - - -// F, G, H and I are basic MD5 functions. - -inline unsigned int MD5::F (uint4 x, uint4 y, uint4 z){ - return (x & y) | (~x & z); -} - -inline unsigned int MD5::G (uint4 x, uint4 y, uint4 z){ - return (x & z) | (y & ~z); -} - -inline unsigned int MD5::H (uint4 x, uint4 y, uint4 z){ - return x ^ y ^ z; -} - -inline unsigned int MD5::I (uint4 x, uint4 y, uint4 z){ - return y ^ (x | ~z); -} - - - -// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. -// Rotation is separate from addition to prevent recomputation. - - -inline void MD5::FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac){ - a += F(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -inline void MD5::GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac){ - a += G(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -inline void MD5::HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac){ - a += H(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -inline void MD5::II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac){ - a += I(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} diff --git a/sourcepawn/jit/md5/md5.h b/sourcepawn/jit/md5/md5.h deleted file mode 100644 index 3f6979d9..00000000 --- a/sourcepawn/jit/md5/md5.h +++ /dev/null @@ -1,106 +0,0 @@ -// MD5.CC - source code for the C++/object oriented translation and -// modification of MD5. - -// Translation and modification (c) 1995 by Mordechai T. Abzug - -// This translation/ modification is provided "as is," without express or -// implied warranty of any kind. - -// The translator/ modifier does not claim (1) that MD5 will do what you think -// it does; (2) that this translation/ modification is accurate; or (3) that -// this software is "merchantible." (Language for this disclaimer partially -// copied from the disclaimer below). - -/* based on: - - MD5.H - header file for MD5C.C - MDDRIVER.C - test driver for MD2, MD4 and MD5 - - Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - -*/ - -#include -//#include -//#include - -class MD5 { - -public: -// methods for controlled operation: - MD5 (); // simple initializer - void update (unsigned char *input, unsigned int input_length); - void update (FILE *file); - void finalize (); - -// constructors for special circumstances. All these constructors finalize -// the MD5 context. - MD5 (unsigned char *string); // digest string, finalize - MD5 (FILE *file); // digest file, close, finalize - -// methods to acquire finalized result - unsigned char *raw_digest (); // digest as a 16-byte binary array - unsigned char *raw_digest(unsigned char buffer[16]); - char * hex_digest (); // digest as a 33-byte ascii-hex string - char * hex_digest (char buffer[33]); //same as above, passing buffer - - - -private: - -// first, some types: - typedef unsigned int uint4; // assumes integer is 4 words long - typedef unsigned short int uint2; // assumes short integer is 2 words long - typedef unsigned char uint1; // assumes char is 1 word long - -// next, the private data: - uint4 state[4]; - uint4 count[2]; // number of *bits*, mod 2^64 - uint1 buffer[64]; // input buffer - uint1 digest[16]; - uint1 finalized; - -// last, the private methods, mostly static: - void init (); // called by all constructors - void transform (uint1 *buffer); // does the real update work. Note - // that length is implied to be 64. - - static void encode (uint1 *dest, uint4 *src, uint4 length); - static void decode (uint4 *dest, uint1 *src, uint4 length); - static void memcpy (uint1 *dest, uint1 *src, uint4 length); - static void memset (uint1 *start, uint1 val, uint4 length); - - static inline uint4 rotate_left (uint4 x, uint4 n); - static inline uint4 F (uint4 x, uint4 y, uint4 z); - static inline uint4 G (uint4 x, uint4 y, uint4 z); - static inline uint4 H (uint4 x, uint4 y, uint4 z); - static inline uint4 I (uint4 x, uint4 y, uint4 z); - static inline void FF (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - static inline void GG (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - static inline void HH (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - static inline void II (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - -}; diff --git a/sourcepawn/jit/msvc10/jit-x86.sln b/sourcepawn/jit/msvc10/jit-x86.sln deleted file mode 100644 index 78d36a8d..00000000 --- a/sourcepawn/jit/msvc10/jit-x86.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jit-x86", "jit-x86.vcxproj", "{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/sourcepawn/jit/msvc10/jit-x86.vcxproj b/sourcepawn/jit/msvc10/jit-x86.vcxproj deleted file mode 100644 index 32fa151a..00000000 --- a/sourcepawn/jit/msvc10/jit-x86.vcxproj +++ /dev/null @@ -1,167 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {307D9D61-51CA-4392-B111-4A3B4229100C} - jitx86 - Win32Proj - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - sourcepawn.jit.x86 - - - sourcepawn.jit.x86 - - - - Disabled - ..;..\x86;..\..\..\public;..\..\..\public\jit;..\..\..\public\jit\x86;..\..\..\public\sourcepawn;..\..\..\knight\shared;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - - Level3 - EditAndContinue - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - ..\..\..\public - - - - - Speed - ..;..\x86;..\..\..\public;..\..\..\public\jit;..\..\..\public\jit\x86;..\..\..\public\sourcepawn;..\..\..\knight\shared;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;JITX86_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - - Level3 - ProgramDatabase - - - $(OutDir)$(TargetFileName) - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - - MachineX86 - - - IF NOT "%SMOUTDIR%"=="" copy /Y "$(TargetDir)$(TargetFileName)" "%SMOUTDIR%\bin" - - - ..\..\..\public - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sourcepawn/jit/msvc10/jit-x86.vcxproj.filters b/sourcepawn/jit/msvc10/jit-x86.vcxproj.filters deleted file mode 100644 index f2f2205b..00000000 --- a/sourcepawn/jit/msvc10/jit-x86.vcxproj.filters +++ /dev/null @@ -1,155 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {ed70871e-c6be-42d0-af01-c8b08e7645b3} - - - {be3a7952-1237-418c-82bb-d56f3b0f9204} - - - {a4ac4f24-40e4-481c-9bd8-42a6f5b379f0} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - zlib - - - zlib - - - zlib - - - zlib - - - zlib - - - zlib - - - zlib - - - zlib - - - zlib - - - zlib - - - zlib - - - zlib - - - md5 - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - SDK - - - SDK - - - SDK - - - SDK - - - SDK - - - md5 - - - - - Resource Files - - - \ No newline at end of file diff --git a/sourcepawn/jit/msvc8/jit-x86.sln b/sourcepawn/jit/msvc8/jit-x86.sln deleted file mode 100644 index 149b2fc1..00000000 --- a/sourcepawn/jit/msvc8/jit-x86.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jit-x86", "jit-x86.vcproj", "{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/sourcepawn/jit/msvc8/jit-x86.vcproj b/sourcepawn/jit/msvc8/jit-x86.vcproj deleted file mode 100644 index 0cb5da49..00000000 --- a/sourcepawn/jit/msvc8/jit-x86.vcproj +++ /dev/null @@ -1,368 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sourcepawn/jit/msvc9/jit-x86.sln b/sourcepawn/jit/msvc9/jit-x86.sln deleted file mode 100644 index 311d9cb7..00000000 --- a/sourcepawn/jit/msvc9/jit-x86.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jit-x86", "jit-x86.vcproj", "{6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.ActiveCfg = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Debug|Win32.Build.0 = Debug|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.ActiveCfg = Release|Win32 - {6EF06E6E-0ED5-4E2D-A8F3-01DD1EC25BA7}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/sourcepawn/jit/msvc9/jit-x86.vcproj b/sourcepawn/jit/msvc9/jit-x86.vcproj deleted file mode 100644 index aae61520..00000000 --- a/sourcepawn/jit/msvc9/jit-x86.vcproj +++ /dev/null @@ -1,367 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sourcepawn/jit/opcodes.cpp b/sourcepawn/jit/opcodes.cpp deleted file mode 100644 index c2cf3eb9..00000000 --- a/sourcepawn/jit/opcodes.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/** - * vim: set ts=8 sw=2 tw=99 sts=2 et: - * ============================================================================= - * 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 . - * - * 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 . - * - * Version: $Id$ - */ -#include "opcodes.h" -#include "jit_shared.h" - -using namespace sp; -using namespace SourcePawn; - -const char *OpcodeNames[] = { -#define _(op, text) text, - OPCODE_LIST(_) -#undef _ - NULL -}; - -void -SourcePawn::SpewOpcode(const sp_plugin_t *plugin, cell_t *start, cell_t *cip) -{ - fprintf(stdout, " [%05d:%04d]", cip - (cell_t *)plugin->pcode, cip - start); - - if (*cip >= OPCODES_TOTAL) { - fprintf(stdout, " unknown-opcode\n"); - return; - } - - OPCODE op = (OPCODE)*cip; - fprintf(stdout, " %s ", OpcodeNames[op]); - - switch (op) { - case OP_PUSH_C: - case OP_PUSH_ADR: - case OP_SHL_C_PRI: - case OP_SHL_C_ALT: - case OP_SHR_C_PRI: - case OP_SHR_C_ALT: - case OP_ADD_C: - case OP_SMUL_C: - case OP_EQ_C_PRI: - case OP_EQ_C_ALT: - case OP_TRACKER_PUSH_C: - case OP_STACK: - case OP_PUSH_S: - case OP_HEAP: - case OP_GENARRAY: - case OP_GENARRAY_Z: - case OP_CONST_PRI: - case OP_CONST_ALT: - fprintf(stdout, "%d", cip[1]); - break; - - case OP_JUMP: - case OP_JZER: - case OP_JNZ: - case OP_JEQ: - case OP_JNEQ: - case OP_JSLESS: - case OP_JSGRTR: - case OP_JSGEQ: - case OP_JSLEQ: - fprintf(stdout, "%05d:%04d", - cip[1] / 4, - ((cell_t *)plugin->pcode + cip[1] / 4) - start); - break; - - case OP_SYSREQ_C: - case OP_SYSREQ_N: - { - uint32_t index = cip[1]; - if (index < plugin->num_natives) - fprintf(stdout, "%s", plugin->natives[index].name); - if (op == OP_SYSREQ_N) - fprintf(stdout, " ; (%d args, index %d)", cip[2], index); - else - fprintf(stdout, " ; (index %d)", index); - break; - } - - case OP_PUSH2_C: - case OP_PUSH2: - case OP_PUSH2_S: - case OP_PUSH2_ADR: - fprintf(stdout, "%d, %d", cip[1], cip[2]); - break; - - case OP_PUSH3_C: - case OP_PUSH3: - case OP_PUSH3_S: - case OP_PUSH3_ADR: - fprintf(stdout, "%d, %d, %d", cip[1], cip[2], cip[3]); - break; - - case OP_PUSH4_C: - case OP_PUSH4: - case OP_PUSH4_S: - case OP_PUSH4_ADR: - fprintf(stdout, "%d, %d, %d, %d", cip[1], cip[2], cip[3], cip[4]); - break; - - case OP_PUSH5_C: - case OP_PUSH5: - case OP_PUSH5_S: - case OP_PUSH5_ADR: - fprintf(stdout, "%d, %d, %d, %d, %d", cip[1], cip[2], cip[3], cip[4], cip[5]); - break; - - default: - break; - } - - fprintf(stdout, "\n"); -} - diff --git a/sourcepawn/jit/opcodes.h b/sourcepawn/jit/opcodes.h deleted file mode 100644 index 963535ec..00000000 --- a/sourcepawn/jit/opcodes.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * vim: set ts=8 sw=2 tw=99 sts=2 et: - * ============================================================================= - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEPAWN_JIT_X86_OPCODES_H_ -#define _INCLUDE_SOURCEPAWN_JIT_X86_OPCODES_H_ - -#include -#include "jit_shared.h" - -namespace SourcePawn { - void SpewOpcode(const sp_plugin_t *plugin, cell_t *start, cell_t *cip); -} - -#endif //_INCLUDE_SOURCEPAWN_JIT_X86_OPCODES_H_ diff --git a/sourcepawn/jit/sp_vm_basecontext.cpp b/sourcepawn/jit/sp_vm_basecontext.cpp deleted file mode 100644 index dbd4c1dd..00000000 --- a/sourcepawn/jit/sp_vm_basecontext.cpp +++ /dev/null @@ -1,861 +0,0 @@ -/** - * vim: set ts=4 sw=4 tw=99 noet: - * ============================================================================= - * SourcePawn - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#include -#include -#include -#include -#include "sp_vm_api.h" -#include "sp_vm_basecontext.h" -#include "sp_vm_engine.h" -#include "watchdog_timer.h" -#include "x86/jit_x86.h" -#include "engine2.h" -#include "interpreter.h" - -using namespace SourcePawn; - -#define CELLBOUNDMAX (INT_MAX/sizeof(cell_t)) -#define STACKMARGIN ((cell_t)(16*sizeof(cell_t))) - -BaseContext::BaseContext(BaseRuntime *pRuntime) -{ - m_pRuntime = pRuntime; - - m_InExec = false; - m_CustomMsg = false; - - /* Initialize the null references */ - uint32_t index; - if (FindPubvarByName("NULL_VECTOR", &index) == SP_ERROR_NONE) - { - sp_pubvar_t *pubvar; - GetPubvarByIndex(index, &pubvar); - m_pNullVec = pubvar->offs; - } - else - { - m_pNullVec = NULL; - } - - if (FindPubvarByName("NULL_STRING", &index) == SP_ERROR_NONE) - { - sp_pubvar_t *pubvar; - GetPubvarByIndex(index, &pubvar); - m_pNullString = pubvar->offs; - } - else - { - m_pNullString = NULL; - } - - m_ctx.hp = m_pRuntime->plugin()->data_size; - m_ctx.sp = m_pRuntime->plugin()->mem_size - sizeof(cell_t); - m_ctx.frm = m_ctx.sp; - m_ctx.n_err = SP_ERROR_NONE; - m_ctx.n_idx = SP_ERROR_NONE; - m_ctx.rp = 0; - - g_Jit.SetupContextVars(m_pRuntime, this, &m_ctx); -} - -BaseContext::~BaseContext() -{ - g_Jit.FreeContextVars(&m_ctx); -} - -IVirtualMachine *BaseContext::GetVirtualMachine() -{ - return NULL; -} - -sp_context_t *BaseContext::GetContext() -{ - return reinterpret_cast((IPluginContext * )this); -} - -sp_context_t *BaseContext::GetCtx() -{ - return &m_ctx; -} - -bool BaseContext::IsDebugging() -{ - return true; -} - -int BaseContext::SetDebugBreak(void *newpfn, void *oldpfn) -{ - return SP_ERROR_ABORTED; -} - -IPluginDebugInfo *BaseContext::GetDebugInfo() -{ - return NULL; -} - -int BaseContext::Execute(uint32_t code_addr, cell_t *result) -{ - return SP_ERROR_ABORTED; -} - -void BaseContext::SetErrorMessage(const char *msg, va_list ap) -{ - m_CustomMsg = true; - - vsnprintf(m_MsgCache, sizeof(m_MsgCache), msg, ap); -} - -void BaseContext::_SetErrorMessage(const char *msg, ...) -{ - va_list ap; - va_start(ap, msg); - SetErrorMessage(msg, ap); - va_end(ap); -} - -cell_t BaseContext::ThrowNativeErrorEx(int error, const char *msg, ...) -{ - if (!m_InExec) - { - return 0; - } - - m_ctx.n_err = error; - - if (msg) - { - va_list ap; - va_start(ap, msg); - SetErrorMessage(msg, ap); - va_end(ap); - } - - return 0; -} - -cell_t BaseContext::ThrowNativeError(const char *msg, ...) -{ - if (!m_InExec) - { - return 0; - } - - m_ctx.n_err = SP_ERROR_NATIVE; - - if (msg) - { - va_list ap; - va_start(ap, msg); - SetErrorMessage(msg, ap); - va_end(ap); - } - - return 0; -} - -int BaseContext::HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr) -{ - cell_t *addr; - ucell_t realmem; - -#if 0 - if (cells > CELLBOUNDMAX) - { - return SP_ERROR_ARAM; - } -#else - assert(cells < CELLBOUNDMAX); -#endif - - realmem = cells * sizeof(cell_t); - - /** - * Check if the space between the heap and stack is sufficient. - */ - if ((cell_t)(m_ctx.sp - m_ctx.hp - realmem) < STACKMARGIN) - { - return SP_ERROR_HEAPLOW; - } - - addr = (cell_t *)(m_pRuntime->plugin()->memory + m_ctx.hp); - /* store size of allocation in cells */ - *addr = (cell_t)cells; - addr++; - m_ctx.hp += sizeof(cell_t); - - *local_addr = m_ctx.hp; - - if (phys_addr) - { - *phys_addr = addr; - } - - m_ctx.hp += realmem; - - return SP_ERROR_NONE; -} - -int BaseContext::HeapPop(cell_t local_addr) -{ - cell_t cellcount; - cell_t *addr; - - /* check the bounds of this address */ - local_addr -= sizeof(cell_t); - if (local_addr < (cell_t)m_pRuntime->plugin()->data_size || local_addr >= m_ctx.sp) - { - return SP_ERROR_INVALID_ADDRESS; - } - - addr = (cell_t *)(m_pRuntime->plugin()->memory + local_addr); - cellcount = (*addr) * sizeof(cell_t); - /* check if this memory count looks valid */ - if ((signed)(m_ctx.hp - cellcount - sizeof(cell_t)) != local_addr) - { - return SP_ERROR_INVALID_ADDRESS; - } - - m_ctx.hp = local_addr; - - return SP_ERROR_NONE; -} - - -int BaseContext::HeapRelease(cell_t local_addr) -{ - if (local_addr < (cell_t)m_pRuntime->plugin()->data_size) - { - return SP_ERROR_INVALID_ADDRESS; - } - - m_ctx.hp = local_addr - sizeof(cell_t); - - return SP_ERROR_NONE; -} - -int BaseContext::FindNativeByName(const char *name, uint32_t *index) -{ - return m_pRuntime->FindNativeByName(name, index); -} - -int BaseContext::GetNativeByIndex(uint32_t index, sp_native_t **native) -{ - return m_pRuntime->GetNativeByIndex(index, native); -} - - -uint32_t BaseContext::GetNativesNum() -{ - return m_pRuntime->GetNativesNum(); -} - -int BaseContext::FindPublicByName(const char *name, uint32_t *index) -{ - return m_pRuntime->FindPublicByName(name, index); -} - -int BaseContext::GetPublicByIndex(uint32_t index, sp_public_t **pblic) -{ - return m_pRuntime->GetPublicByIndex(index, pblic); -} - -uint32_t BaseContext::GetPublicsNum() -{ - return m_pRuntime->GetPublicsNum(); -} - -int BaseContext::GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar) -{ - return m_pRuntime->GetPubvarByIndex(index, pubvar); -} - -int BaseContext::FindPubvarByName(const char *name, uint32_t *index) -{ - return m_pRuntime->FindPubvarByName(name, index); -} - -int BaseContext::GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr) -{ - return m_pRuntime->GetPubvarAddrs(index, local_addr, phys_addr); -} - -uint32_t BaseContext::GetPubVarsNum() -{ - return m_pRuntime->GetPubVarsNum(); -} - -int BaseContext::BindNatives(const sp_nativeinfo_t *natives, unsigned int num, int overwrite) -{ - return SP_ERROR_ABORTED; -} - -int BaseContext::BindNative(const sp_nativeinfo_t *native) -{ - return SP_ERROR_ABORTED; -} - -int BaseContext::BindNativeToIndex(uint32_t index, SPVM_NATIVE_FUNC func) -{ - return SP_ERROR_ABORTED; -} - -int BaseContext::BindNativeToAny(SPVM_NATIVE_FUNC native) -{ - return SP_ERROR_ABORTED; -} - -int BaseContext::LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr) -{ - if (((local_addr >= m_ctx.hp) && (local_addr < m_ctx.sp)) - || (local_addr < 0) || ((ucell_t)local_addr >= m_pRuntime->plugin()->mem_size)) - { - return SP_ERROR_INVALID_ADDRESS; - } - - if (phys_addr) - { - *phys_addr = (cell_t *)(m_pRuntime->plugin()->memory + local_addr); - } - - return SP_ERROR_NONE; -} - -int BaseContext::PushCell(cell_t value) -{ - return SP_ERROR_ABORTED; -} - -int BaseContext::PushCellsFromArray(cell_t array[], unsigned int numcells) -{ - return SP_ERROR_ABORTED; -} - -int BaseContext::PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells) -{ - return SP_ERROR_ABORTED; -} - -int BaseContext::LocalToString(cell_t local_addr, char **addr) -{ - if (((local_addr >= m_ctx.hp) && (local_addr < m_ctx.sp)) - || (local_addr < 0) || ((ucell_t)local_addr >= m_pRuntime->plugin()->mem_size)) - { - return SP_ERROR_INVALID_ADDRESS; - } - *addr = (char *)(m_pRuntime->plugin()->memory + local_addr); - - return SP_ERROR_NONE; -} - -int BaseContext::PushString(cell_t *local_addr, char **phys_addr, const char *string) -{ - return SP_ERROR_ABORTED; -} - -int BaseContext::StringToLocal(cell_t local_addr, size_t bytes, const char *source) -{ - char *dest; - size_t len; - - if (((local_addr >= m_ctx.hp) && (local_addr < m_ctx.sp)) - || (local_addr < 0) || ((ucell_t)local_addr >= m_pRuntime->plugin()->mem_size)) - { - return SP_ERROR_INVALID_ADDRESS; - } - - if (bytes == 0) - { - return SP_ERROR_NONE; - } - - len = strlen(source); - dest = (char *)(m_pRuntime->plugin()->memory + local_addr); - - if (len >= bytes) - { - len = bytes - 1; - } - - memmove(dest, source, len); - dest[len] = '\0'; - - return SP_ERROR_NONE; -} - -inline int __CheckValidChar(char *c) -{ - int count; - int bytecount = 0; - - for (count=1; (*c & 0xC0) == 0x80; count++) - { - c--; - } - - switch (*c & 0xF0) - { - case 0xC0: - case 0xD0: - { - bytecount = 2; - break; - } - case 0xE0: - { - bytecount = 3; - break; - } - case 0xF0: - { - bytecount = 4; - break; - } - } - - if (bytecount != count) - { - return count; - } - - return 0; -} - -int BaseContext::StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const char *source, size_t *wrtnbytes) -{ - char *dest; - size_t len; - bool needtocheck = false; - - if (((local_addr >= m_ctx.hp) && (local_addr < m_ctx.sp)) - || (local_addr < 0) - || ((ucell_t)local_addr >= m_pRuntime->plugin()->mem_size)) - { - return SP_ERROR_INVALID_ADDRESS; - } - - if (maxbytes == 0) - { - return SP_ERROR_NONE; - } - - len = strlen(source); - dest = (char *)(m_pRuntime->plugin()->memory + local_addr); - - if ((size_t)len >= maxbytes) - { - len = maxbytes - 1; - needtocheck = true; - } - - memmove(dest, source, len); - if ((dest[len-1] & 1<<7) && needtocheck) - { - len -= __CheckValidChar(dest+len-1); - } - dest[len] = '\0'; - - if (wrtnbytes) - { - *wrtnbytes = len; - } - - return SP_ERROR_NONE; -} - -IPluginFunction *BaseContext::GetFunctionById(funcid_t func_id) -{ - return m_pRuntime->GetFunctionById(func_id); -} - -IPluginFunction *BaseContext::GetFunctionByName(const char *public_name) -{ - return m_pRuntime->GetFunctionByName(public_name); -} - -int BaseContext::LocalToStringNULL(cell_t local_addr, char **addr) -{ - int err; - if ((err = LocalToString(local_addr, addr)) != SP_ERROR_NONE) - { - return err; - } - - if ((cell_t *)*addr == m_pNullString) - { - *addr = NULL; - } - - return SP_ERROR_NONE; -} - -SourceMod::IdentityToken_t *BaseContext::GetIdentity() -{ - SourceMod::IdentityToken_t *tok; - - if (GetKey(1, (void **)&tok)) - { - return tok; - } - - return NULL; -} - -cell_t *BaseContext::GetNullRef(SP_NULL_TYPE type) -{ - if (type == SP_NULL_VECTOR) - { - return m_pNullVec; - } - - return NULL; -} - -bool BaseContext::IsInExec() -{ - return m_InExec; -} - -int BaseContext::Execute2(IPluginFunction *function, const cell_t *params, unsigned int num_params, cell_t *result) -{ - int ir; - int serial; - cell_t *sp; - JitFunction *fn; - cell_t _ignore_result; - - EnterProfileScope profileScope("SourcePawn", "EnterJIT"); - - if (!g_WatchdogTimer.HandleInterrupt()) - return SP_ERROR_TIMEOUT; - - funcid_t fnid = function->GetFunctionID(); - if (!(fnid & 1)) - return SP_ERROR_INVALID_ADDRESS; - - unsigned public_id = fnid >> 1; - CFunction *cfun = m_pRuntime->GetPublicFunction(public_id); - if (!cfun) - return SP_ERROR_NOT_FOUND; - - if (m_pRuntime->IsPaused()) - return SP_ERROR_NOT_RUNNABLE; - - if ((cell_t)(m_ctx.hp + 16*sizeof(cell_t)) > (cell_t)(m_ctx.sp - (sizeof(cell_t) * (num_params + 1)))) - return SP_ERROR_STACKLOW; - - if (result == NULL) - result = &_ignore_result; - - /* We got this far. It's time to start profiling. */ - EnterProfileScope scriptScope("SourcePawn", cfun->FullName()); - - /* See if we have to compile the callee. */ - if (g_engine2.IsJitEnabled() && (fn = m_pRuntime->m_PubJitFuncs[public_id]) == NULL) - { - /* We might not have to - check pcode offset. */ - fn = m_pRuntime->GetJittedFunctionByOffset(cfun->Public()->code_offs); - if (fn) - { - m_pRuntime->m_PubJitFuncs[public_id] = fn; - } - else - { - if ((fn = g_Jit.CompileFunction(m_pRuntime, cfun->Public()->code_offs, &ir)) == NULL) - { - return ir; - } - m_pRuntime->m_PubJitFuncs[public_id] = fn; - } - } - - /* Save our previous state. */ - - bool save_exec; - uint32_t save_n_idx; - cell_t save_sp, save_hp, save_rp, save_cip; - - save_sp = m_ctx.sp; - save_hp = m_ctx.hp; - save_exec = m_InExec; - save_n_idx = m_ctx.n_idx; - save_rp = m_ctx.rp; - save_cip = m_ctx.cip; - - /* Push parameters */ - - m_ctx.sp -= sizeof(cell_t) * (num_params + 1); - sp = (cell_t *)(m_pRuntime->plugin()->memory + m_ctx.sp); - - sp[0] = num_params; - for (unsigned int i = 0; i < num_params; i++) - { - sp[i + 1] = params[i]; - } - - /* Clear internal state */ - m_ctx.n_err = SP_ERROR_NONE; - m_ctx.n_idx = 0; - m_MsgCache[0] = '\0'; - m_CustomMsg = false; - m_InExec = true; - - /* Start the frame tracer */ - - if (g_engine2.IsJitEnabled()) - ir = g_Jit.InvokeFunction(m_pRuntime, fn, result); - else - ir = Interpret(m_pRuntime, cfun->Public()->code_offs, result); - - /* Restore some states, stop the frame tracer */ - - m_InExec = save_exec; - - if (ir == SP_ERROR_NONE) - { - m_ctx.n_err = SP_ERROR_NONE; - if (m_ctx.sp != save_sp) - { - ir = SP_ERROR_STACKLEAK; - _SetErrorMessage("Stack leak detected: sp:%d should be %d!", - m_ctx.sp, - save_sp); - } - if (m_ctx.hp != save_hp) - { - ir = SP_ERROR_HEAPLEAK; - _SetErrorMessage("Heap leak detected: hp:%d should be %d!", - m_ctx.hp, - save_hp); - } - if (m_ctx.rp != save_rp) - { - ir = SP_ERROR_STACKLEAK; - _SetErrorMessage("Return stack leak detected: rp:%d should be %d!", - m_ctx.rp, - save_rp); - } - } - - if (ir == SP_ERROR_TIMEOUT) - g_WatchdogTimer.NotifyTimeoutReceived(); - - if (ir != SP_ERROR_NONE) - { - g_engine1.ReportError(m_pRuntime, ir, m_MsgCache, save_rp); - } - - m_ctx.sp = save_sp; - m_ctx.hp = save_hp; - m_ctx.rp = save_rp; - - m_ctx.cip = save_cip; - m_ctx.n_idx = save_n_idx; - m_ctx.n_err = SP_ERROR_NONE; - m_MsgCache[0] = '\0'; - m_CustomMsg = false; - - return ir; -} - -IPluginRuntime *BaseContext::GetRuntime() -{ - return m_pRuntime; -} - -DebugInfo::DebugInfo(sp_plugin_t *plugin) : m_pPlugin(plugin) -{ -} - -#define USHR(x) ((unsigned int)(x)>>1) - -int DebugInfo::LookupFile(ucell_t addr, const char **filename) -{ - int high, low, mid; - - high = m_pPlugin->debug.files_num; - low = -1; - - while (high - low > 1) - { - mid = USHR(low + high); - if (m_pPlugin->debug.files[mid].addr <= addr) - { - low = mid; - } else { - high = mid; - } - } - - if (low == -1) - { - return SP_ERROR_NOT_FOUND; - } - - *filename = m_pPlugin->debug.stringbase + m_pPlugin->debug.files[low].name; - - return SP_ERROR_NONE; -} - -int DebugInfo::LookupFunction(ucell_t addr, const char **name) -{ - if (!m_pPlugin->debug.unpacked) - { - uint32_t max, iter; - sp_fdbg_symbol_t *sym; - uint8_t *cursor = (uint8_t *)(m_pPlugin->debug.symbols); - - max = m_pPlugin->debug.syms_num; - for (iter = 0; iter < max; iter++) - { - sym = (sp_fdbg_symbol_t *)cursor; - - if (sym->ident == sp::IDENT_FUNCTION - && sym->codestart <= addr - && sym->codeend > addr) - { - *name = m_pPlugin->debug.stringbase + sym->name; - return SP_ERROR_NONE; - } - - if (sym->dimcount > 0) - { - cursor += sizeof(sp_fdbg_symbol_t); - cursor += sizeof(sp_fdbg_arraydim_t) * sym->dimcount; - continue; - } - - cursor += sizeof(sp_fdbg_symbol_t); - } - - return SP_ERROR_NOT_FOUND; - } - else - { - uint32_t max, iter; - sp_u_fdbg_symbol_t *sym; - uint8_t *cursor = (uint8_t *)(m_pPlugin->debug.symbols); - - max = m_pPlugin->debug.syms_num; - for (iter = 0; iter < max; iter++) - { - sym = (sp_u_fdbg_symbol_t *)cursor; - - if (sym->ident == sp::IDENT_FUNCTION - && sym->codestart <= addr - && sym->codeend > addr) - { - *name = m_pPlugin->debug.stringbase + sym->name; - return SP_ERROR_NONE; - } - - if (sym->dimcount > 0) - { - cursor += sizeof(sp_u_fdbg_symbol_t); - cursor += sizeof(sp_u_fdbg_arraydim_t) * sym->dimcount; - continue; - } - - cursor += sizeof(sp_u_fdbg_symbol_t); - } - - return SP_ERROR_NOT_FOUND; - } -} - -int DebugInfo::LookupLine(ucell_t addr, uint32_t *line) -{ - int high, low, mid; - - high = m_pPlugin->debug.lines_num; - low = -1; - - while (high - low > 1) - { - mid = USHR(low + high); - if (m_pPlugin->debug.lines[mid].addr <= addr) - { - low = mid; - } else { - high = mid; - } - } - - if (low == -1) - { - return SP_ERROR_NOT_FOUND; - } - - /* Since the CIP occurs BEFORE the line, we have to add one */ - *line = m_pPlugin->debug.lines[low].line + 1; - - return SP_ERROR_NONE; -} - -#undef USHR - -int BaseContext::GetLastNativeError() -{ - return m_ctx.n_err; -} - -cell_t *BaseContext::GetLocalParams() -{ - return (cell_t *)(m_pRuntime->plugin()->memory + m_ctx.frm + (2 * sizeof(cell_t))); -} - -void BaseContext::SetKey(int k, void *value) -{ - if (k < 1 || k > 4) - { - return; - } - - m_keys[k - 1] = value; - m_keys_set[k - 1] = true; -} - -bool BaseContext::GetKey(int k, void **value) -{ - if (k < 1 || k > 4 || m_keys_set[k - 1] == false) - { - return false; - } - - *value = m_keys[k - 1]; - - return true; -} - -void BaseContext::ClearLastNativeError() -{ - m_ctx.n_err = SP_ERROR_NONE; -} diff --git a/sourcepawn/jit/sp_vm_basecontext.h b/sourcepawn/jit/sp_vm_basecontext.h deleted file mode 100644 index dce3c9fa..00000000 --- a/sourcepawn/jit/sp_vm_basecontext.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - * vim: set ts=4 : - * ============================================================================= - * SourcePawn - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEPAWN_BASECONTEXT_H_ -#define _INCLUDE_SOURCEPAWN_BASECONTEXT_H_ - -#include "sp_vm_api.h" -#include "sp_vm_function.h" -#include "BaseRuntime.h" -#include "jit_shared.h" - -/** - * :TODO: Make functions allocate as a lump instead of individual allocations! - */ - -class BaseContext : public IPluginContext -{ -public: - BaseContext(BaseRuntime *pRuntime); - ~BaseContext(); -public: //IPluginContext - IVirtualMachine *GetVirtualMachine(); - sp_context_t *GetContext(); - sp_context_t *GetCtx(); - bool IsDebugging(); - int SetDebugBreak(void *newpfn, void *oldpfn); - IPluginDebugInfo *GetDebugInfo(); - int HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr); - int HeapPop(cell_t local_addr); - int HeapRelease(cell_t local_addr); - int FindNativeByName(const char *name, uint32_t *index); - int GetNativeByIndex(uint32_t index, sp_native_t **native); - uint32_t GetNativesNum(); - int FindPublicByName(const char *name, uint32_t *index); - int GetPublicByIndex(uint32_t index, sp_public_t **publicptr); - uint32_t GetPublicsNum(); - int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar); - int FindPubvarByName(const char *name, uint32_t *index); - int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr); - uint32_t GetPubVarsNum(); - int LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr); - int LocalToString(cell_t local_addr, char **addr); - int StringToLocal(cell_t local_addr, size_t chars, const char *source); - int StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const char *source, size_t *wrtnbytes); - int PushCell(cell_t value); - int PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells); - int PushString(cell_t *local_addr, char **phys_addr, const char *string); - int PushCellsFromArray(cell_t array[], unsigned int numcells); - int BindNatives(const sp_nativeinfo_t *natives, unsigned int num, int overwrite); - int BindNative(const sp_nativeinfo_t *native); - int BindNativeToAny(SPVM_NATIVE_FUNC native); - int Execute(uint32_t code_addr, cell_t *result); - cell_t ThrowNativeErrorEx(int error, const char *msg, ...); - cell_t ThrowNativeError(const char *msg, ...); - IPluginFunction *GetFunctionByName(const char *public_name); - IPluginFunction *GetFunctionById(funcid_t func_id); - SourceMod::IdentityToken_t *GetIdentity(); - cell_t *GetNullRef(SP_NULL_TYPE type); - int LocalToStringNULL(cell_t local_addr, char **addr); - int BindNativeToIndex(uint32_t index, SPVM_NATIVE_FUNC native); - int Execute2(IPluginFunction *function, const cell_t *params, unsigned int num_params, cell_t *result); - IPluginRuntime *GetRuntime(); - int GetLastNativeError(); - cell_t *GetLocalParams(); - void SetKey(int k, void *value); - bool GetKey(int k, void **value); - void Refresh(); - void ClearLastNativeError(); -public: - bool IsInExec(); -private: - void SetErrorMessage(const char *msg, va_list ap); - void _SetErrorMessage(const char *msg, ...); -private: - cell_t *m_pNullVec; - cell_t *m_pNullString; - char m_MsgCache[1024]; - bool m_CustomMsg; - bool m_InExec; - BaseRuntime *m_pRuntime; - sp_context_t m_ctx; - void *m_keys[4]; - bool m_keys_set[4]; -}; - -#endif //_INCLUDE_SOURCEPAWN_BASECONTEXT_H_ diff --git a/sourcepawn/jit/sp_vm_engine.cpp b/sourcepawn/jit/sp_vm_engine.cpp deleted file mode 100644 index 4c314b20..00000000 --- a/sourcepawn/jit/sp_vm_engine.cpp +++ /dev/null @@ -1,354 +0,0 @@ -/** - * vim: set ts=4 sw=4 tw=99 et: - * ============================================================================= - * SourcePawn - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#include -#include -#include -#include "sp_vm_types.h" -#include -#include "sp_vm_engine.h" -#include "zlib/zlib.h" -#include "sp_vm_basecontext.h" -#include "jit_x86.h" -#if defined __GNUC__ -#include -#endif - -SourcePawnEngine g_engine1; - -#if defined WIN32 - #define WIN32_LEAN_AND_MEAN - #include -#elif defined __GNUC__ - #include -#endif - -#if defined __linux__ -#include -#endif - -using namespace SourcePawn; - -#define ERROR_MESSAGE_MAX 30 -static const char *g_ErrorMsgTable[] = -{ - NULL, - "Unrecognizable file format", - "Decompressor was not found", - "Not enough space on the heap", - "Invalid parameter or parameter type", - "Invalid plugin address", - "Object or index not found", - "Invalid index or index not found", - "Not enough space on the stack", - "Debug section not found or debug not enabled", - "Invalid instruction", - "Invalid memory access", - "Stack went below stack boundary", - "Heap went below heap boundary", - "Divide by zero", - "Array index is out of bounds", - "Instruction contained invalid parameter", - "Stack memory leaked by native", - "Heap memory leaked by native", - "Dynamic array is too big", - "Tracker stack is out of bounds", - "Native is not bound", - "Maximum number of parameters reached", - "Native detected error", - "Plugin not runnable", - "Call was aborted", - "Plugin format is too old", - "Plugin format is too new", - "Out of memory", - "Integer overflow", - "Script execution timed out" -}; - -const char *SourcePawnEngine::GetErrorString(int error) -{ - if (error < 1 || error > ERROR_MESSAGE_MAX) - { - return NULL; - } - - return g_ErrorMsgTable[error]; -} - -SourcePawnEngine::SourcePawnEngine() -{ - m_pDebugHook = NULL; -} - -SourcePawnEngine::~SourcePawnEngine() -{ -} - -void *SourcePawnEngine::ExecAlloc(size_t size) -{ -#if defined WIN32 - return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); -#elif defined __GNUC__ -# if defined __APPLE__ - void *base = valloc(size); -# else - void *base = memalign(sysconf(_SC_PAGESIZE), size); -# endif - if (mprotect(base, size, PROT_READ|PROT_WRITE|PROT_EXEC) != 0) - { - free(base); - return NULL; - } - return base; -#endif -} - -void *SourcePawnEngine::AllocatePageMemory(size_t size) -{ - return g_Jit.AllocCode(size); -} - -void SourcePawnEngine::SetReadExecute(void *ptr) -{ - /* already re */ -} - -void SourcePawnEngine::SetReadWrite(void *ptr) -{ - /* already rw */ -} - -void SourcePawnEngine::FreePageMemory(void *ptr) -{ - g_Jit.FreeCode(ptr); -} - -void SourcePawnEngine::ExecFree(void *address) -{ -#if defined WIN32 - VirtualFree(address, 0, MEM_RELEASE); -#elif defined __GNUC__ - free(address); -#endif -} - -void SourcePawnEngine::SetReadWriteExecute(void *ptr) -{ -//:TODO: g_ExeMemory.SetRWE(ptr); - SetReadExecute(ptr); -} - -void *SourcePawnEngine::BaseAlloc(size_t size) -{ - return malloc(size); -} - -void SourcePawnEngine::BaseFree(void *memory) -{ - free(memory); -} - -sp_plugin_t *SourcePawnEngine::LoadFromFilePointer(FILE *fp, int *err) -{ - if (err != NULL) - { - *err = SP_ERROR_ABORTED; - } - - return NULL; -} - -sp_plugin_t *SourcePawnEngine::LoadFromMemory(void *base, sp_plugin_t *plugin, int *err) -{ - if (err != NULL) - { - *err = SP_ERROR_ABORTED; - } - - return NULL; -} - -int SourcePawnEngine::FreeFromMemory(sp_plugin_t *plugin) -{ - return SP_ERROR_ABORTED; -} - -IDebugListener *SourcePawnEngine::SetDebugListener(IDebugListener *pListener) -{ - IDebugListener *old = m_pDebugHook; - - m_pDebugHook = pListener; - - return old; -} - -unsigned int SourcePawnEngine::GetEngineAPIVersion() -{ - return SOURCEPAWN_ENGINE_API_VERSION; -} - -unsigned int SourcePawnEngine::GetContextCallCount() -{ - return 0; -} - -void SourcePawnEngine::ReportError(BaseRuntime *runtime, int err, const char *errstr, cell_t rp_start) -{ - if (m_pDebugHook == NULL) - { - return; - } - - CContextTrace trace(runtime, err, errstr, rp_start); - - m_pDebugHook->OnContextExecuteError(runtime->GetDefaultContext(), &trace); -} - -CContextTrace::CContextTrace(BaseRuntime *pRuntime, int err, const char *errstr, cell_t start_rp) -: m_pRuntime(pRuntime), m_Error(err), m_pMsg(errstr), m_StartRp(start_rp), m_Level(0) -{ - m_ctx = pRuntime->m_pCtx->GetCtx(); - m_pDebug = m_pRuntime->GetDebugInfo(); -} - -bool CContextTrace::DebugInfoAvailable() -{ - return (m_pDebug != NULL); -} - -const char *CContextTrace::GetCustomErrorString() -{ - return m_pMsg; -} - -int CContextTrace::GetErrorCode() -{ - return m_Error; -} - -const char *CContextTrace::GetErrorString() -{ - if (m_Error > ERROR_MESSAGE_MAX || m_Error < 1) - { - return "Invalid error code"; - } - else - { - return g_ErrorMsgTable[m_Error]; - } -} - -void CContextTrace::ResetTrace() -{ - m_Level = 0; -} - -bool CContextTrace::GetTraceInfo(CallStackInfo *trace) -{ - cell_t cip; - - if (m_Level == 0) - { - cip = m_ctx->cip; - } - else if (m_ctx->rp > 0) - { - /* Entries go from ctx.rp - 1 to m_StartRp */ - cell_t offs, start, end; - - offs = m_Level - 1; - start = m_ctx->rp - 1; - end = m_StartRp; - - if (start - offs < end) - { - return false; - } - - cip = m_ctx->rstk_cips[start - offs]; - } - else - { - return false; - } - - if (trace == NULL) - { - m_Level++; - return true; - } - - if (m_pDebug->LookupFile(cip, &(trace->filename)) != SP_ERROR_NONE) - { - trace->filename = NULL; - } - - if (m_pDebug->LookupFunction(cip, &(trace->function)) != SP_ERROR_NONE) - { - trace->function = NULL; - } - - if (m_pDebug->LookupLine(cip, &(trace->line)) != SP_ERROR_NONE) - { - trace->line = 0; - } - - m_Level++; - - return true; -} - -const char *CContextTrace::GetLastNative(uint32_t *index) -{ - if (m_ctx->n_err == SP_ERROR_NONE) - { - return NULL; - } - - sp_native_t *native; - if (m_pRuntime->GetNativeByIndex(m_ctx->n_idx, &native) != SP_ERROR_NONE) - { - return NULL; - } - - if (index) - { - *index = m_ctx->n_idx; - } - - return native->name; -} - -IDebugListener *SourcePawnEngine::GetDebugHook() -{ - return m_pDebugHook; -} - diff --git a/sourcepawn/jit/sp_vm_engine.h b/sourcepawn/jit/sp_vm_engine.h deleted file mode 100644 index 486e83a6..00000000 --- a/sourcepawn/jit/sp_vm_engine.h +++ /dev/null @@ -1,95 +0,0 @@ -/** - * vim: set ts=4 : - * ============================================================================= - * SourcePawn - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEPAWN_VM_ENGINE_H_ -#define _INCLUDE_SOURCEPAWN_VM_ENGINE_H_ - -#include "sp_vm_api.h" -#include "sp_vm_function.h" - -class BaseContext; - -class CContextTrace : public IContextTrace -{ -public: - CContextTrace(BaseRuntime *pRuntime, int err, const char *errstr, cell_t start_rp); -public: - int GetErrorCode(); - const char *GetErrorString(); - bool DebugInfoAvailable(); - const char *GetCustomErrorString(); - bool GetTraceInfo(CallStackInfo *trace); - void ResetTrace(); - const char *GetLastNative(uint32_t *index); -private: - BaseRuntime *m_pRuntime; - sp_context_t *m_ctx; - int m_Error; - const char *m_pMsg; - cell_t m_StartRp; - cell_t m_Level; - IPluginDebugInfo *m_pDebug; -}; - -class SourcePawnEngine : public ISourcePawnEngine -{ -public: - SourcePawnEngine(); - ~SourcePawnEngine(); -public: //ISourcePawnEngine - sp_plugin_t *LoadFromFilePointer(FILE *fp, int *err); - sp_plugin_t *LoadFromMemory(void *base, sp_plugin_t *plugin, int *err); - int FreeFromMemory(sp_plugin_t *plugin); - void *BaseAlloc(size_t size); - void BaseFree(void *memory); - void *ExecAlloc(size_t size); - void ExecFree(void *address); - IDebugListener *SetDebugListener(IDebugListener *pListener); - unsigned int GetContextCallCount(); - unsigned int GetEngineAPIVersion(); - void *AllocatePageMemory(size_t size); - void SetReadWrite(void *ptr); - void SetReadExecute(void *ptr); - void SetReadWriteExecute(void *ptr); - void FreePageMemory(void *ptr); - const char *GetErrorString(int err); - void ReportError(BaseRuntime *runtime, int err, const char *errstr, cell_t rp_start); -public: //Plugin function stuff - CFunction *GetFunctionFromPool(funcid_t f, IPluginContext *plugin); - void ReleaseFunctionToPool(CFunction *func); - IDebugListener *GetDebugHook(); -private: - IDebugListener *m_pDebugHook; -}; - -extern SourcePawnEngine g_engine1; - -#endif //_INCLUDE_SOURCEPAWN_VM_ENGINE_H_ diff --git a/sourcepawn/jit/sp_vm_function.cpp b/sourcepawn/jit/sp_vm_function.cpp deleted file mode 100644 index 3daa77d8..00000000 --- a/sourcepawn/jit/sp_vm_function.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/** - * vim: set ts=4 sw=4 tw=99 noet : - * ============================================================================= - * SourcePawn - * Copyright (C) 2004-2009 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 . - * - * 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 . - */ - -#include -#include -#include "sp_vm_function.h" -#include "BaseRuntime.h" - -/******************** -* FUNCTION CALLING * -********************/ - -CFunction::~CFunction() -{ - delete [] full_name_; -} - -bool CFunction::IsRunnable() -{ - return !m_pRuntime->IsPaused(); -} - -int CFunction::CallFunction(const cell_t *params, unsigned int num_params, cell_t *result) -{ - return CallFunction2(m_pRuntime->GetDefaultContext(), params, num_params, result); -} - -int CFunction::CallFunction2(IPluginContext *pContext, const cell_t *params, unsigned int num_params, cell_t *result) -{ - return pContext->Execute2(this, params, num_params, result); -} - -IPluginContext *CFunction::GetParentContext() -{ - return m_pRuntime->GetDefaultContext(); -} - -CFunction::CFunction(BaseRuntime *runtime, funcid_t id, uint32_t pub_id) : - m_curparam(0), m_errorstate(SP_ERROR_NONE), m_FnId(id) -{ - m_pRuntime = runtime; - - runtime->GetPublicByIndex(pub_id, &public_); - - size_t rt_len = strlen(runtime->plugin()->name); - size_t len = rt_len + strlen("::") + strlen(public_->name); - - full_name_ = new char[len + 1]; - strcpy(full_name_, runtime->plugin()->name); - strcpy(&full_name_[rt_len], "::"); - strcpy(&full_name_[rt_len + 2], public_->name); -} - -int CFunction::PushCell(cell_t cell) -{ - if (m_curparam >= SP_MAX_EXEC_PARAMS) - { - return SetError(SP_ERROR_PARAMS_MAX); - } - - m_info[m_curparam].marked = false; - m_params[m_curparam] = cell; - m_curparam++; - - return SP_ERROR_NONE; -} - -int CFunction::PushCellByRef(cell_t *cell, int flags) -{ - return PushArray(cell, 1, flags); -} - -int CFunction::PushFloat(float number) -{ - cell_t val = *(cell_t *)&number; - - return PushCell(val); -} - -int CFunction::PushFloatByRef(float *number, int flags) -{ - return PushCellByRef((cell_t *)number, flags); -} - -int CFunction::PushArray(cell_t *inarray, unsigned int cells, int copyback) -{ - if (m_curparam >= SP_MAX_EXEC_PARAMS) - { - return SetError(SP_ERROR_PARAMS_MAX); - } - - ParamInfo *info = &m_info[m_curparam]; - - info->flags = inarray ? copyback : 0; - info->marked = true; - info->size = cells; - info->str.is_sz = false; - info->orig_addr = inarray; - - m_curparam++; - - return SP_ERROR_NONE; -} - -int CFunction::PushString(const char *string) -{ - return _PushString(string, SM_PARAM_STRING_COPY, 0, strlen(string)+1); -} - -int CFunction::PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags) -{ - return _PushString(buffer, sz_flags, cp_flags, length); -} - -int CFunction::_PushString(const char *string, int sz_flags, int cp_flags, size_t len) -{ - if (m_curparam >= SP_MAX_EXEC_PARAMS) - { - return SetError(SP_ERROR_PARAMS_MAX); - } - - ParamInfo *info = &m_info[m_curparam]; - - info->marked = true; - info->orig_addr = (cell_t *)string; - info->flags = cp_flags; - info->size = len; - info->str.sz_flags = sz_flags; - info->str.is_sz = true; - - m_curparam++; - - return SP_ERROR_NONE; -} - -void CFunction::Cancel() -{ - if (!m_curparam) - { - return; - } - - m_errorstate = SP_ERROR_NONE; - m_curparam = 0; -} - -int CFunction::Execute(cell_t *result) -{ - return Execute2(m_pRuntime->GetDefaultContext(), result); -} - -int CFunction::Execute2(IPluginContext *ctx, cell_t *result) -{ - int err = SP_ERROR_NONE; - - if (!IsRunnable()) - { - m_errorstate = SP_ERROR_NOT_RUNNABLE; - } - - if (m_errorstate != SP_ERROR_NONE) - { - err = m_errorstate; - Cancel(); - return err; - } - - //This is for re-entrancy! - cell_t temp_params[SP_MAX_EXEC_PARAMS]; - ParamInfo temp_info[SP_MAX_EXEC_PARAMS]; - unsigned int numparams = m_curparam; - unsigned int i; - bool docopies = true; - - if (numparams) - { - //Save the info locally, then reset it for re-entrant calls. - memcpy(temp_info, m_info, numparams * sizeof(ParamInfo)); - } - m_curparam = 0; - - /* Browse the parameters and build arrays */ - for (i=0; iHeapAlloc(temp_info[i].size, - &(temp_info[i].local_addr), - &(temp_info[i].phys_addr))) - != SP_ERROR_NONE) - { - break; - } - if (temp_info[i].orig_addr) - { - memcpy(temp_info[i].phys_addr, temp_info[i].orig_addr, sizeof(cell_t) * temp_info[i].size); - } - } - else - { - /* Calculate cells required for the string */ - size_t cells = (temp_info[i].size + sizeof(cell_t) - 1) / sizeof(cell_t); - - /* Allocate the buffer */ - if ((err=ctx->HeapAlloc(cells, - &(temp_info[i].local_addr), - &(temp_info[i].phys_addr))) - != SP_ERROR_NONE) - { - break; - } - /* Copy original string if necessary */ - if ((temp_info[i].str.sz_flags & SM_PARAM_STRING_COPY) && (temp_info[i].orig_addr != NULL)) - { - /* Cut off UTF-8 properly */ - if (temp_info[i].str.sz_flags & SM_PARAM_STRING_UTF8) - { - if ((err=ctx->StringToLocalUTF8(temp_info[i].local_addr, - temp_info[i].size, - (const char *)temp_info[i].orig_addr, - NULL)) - != SP_ERROR_NONE) - { - break; - } - } - /* Copy a binary blob */ - else if (temp_info[i].str.sz_flags & SM_PARAM_STRING_BINARY) - { - memmove(temp_info[i].phys_addr, temp_info[i].orig_addr, temp_info[i].size); - } - /* Copy ASCII characters */ - else - { - if ((err=ctx->StringToLocal(temp_info[i].local_addr, - temp_info[i].size, - (const char *)temp_info[i].orig_addr)) - != SP_ERROR_NONE) - { - break; - } - } - } - } /* End array/string calculation */ - /* Update the pushed parameter with the byref local address */ - temp_params[i] = temp_info[i].local_addr; - } - else - { - /* Just copy the value normally */ - temp_params[i] = m_params[i]; - } - } - - /* Make the call if we can */ - if (err == SP_ERROR_NONE) - { - if ((err = CallFunction2(ctx, temp_params, numparams, result)) != SP_ERROR_NONE) - { - docopies = false; - } - } - else - { - docopies = false; - } - - /* i should be equal to the last valid parameter + 1 */ - while (i--) - { - if (!temp_info[i].marked) - { - continue; - } - - if (docopies && (temp_info[i].flags & SM_PARAM_COPYBACK)) - { - if (temp_info[i].orig_addr) - { - if (temp_info[i].str.is_sz) - { - memcpy(temp_info[i].orig_addr, temp_info[i].phys_addr, temp_info[i].size); - - } - else - { - if (temp_info[i].size == 1) - { - *temp_info[i].orig_addr = *(temp_info[i].phys_addr); - } - else - { - memcpy(temp_info[i].orig_addr, - temp_info[i].phys_addr, - temp_info[i].size * sizeof(cell_t)); - } - } - } - } - - if ((err=ctx->HeapPop(temp_info[i].local_addr)) != SP_ERROR_NONE) - { - return err; - } - } - - return err; -} - -IPluginRuntime *CFunction::GetParentRuntime() -{ - return m_pRuntime; -} - -funcid_t CFunction::GetFunctionID() -{ - return m_FnId; -} - -int CFunction::SetError(int err) -{ - m_errorstate = err; - - return err; -} - diff --git a/sourcepawn/jit/sp_vm_function.h b/sourcepawn/jit/sp_vm_function.h deleted file mode 100644 index 6c9c0e13..00000000 --- a/sourcepawn/jit/sp_vm_function.h +++ /dev/null @@ -1,106 +0,0 @@ -/** - * vim: set ts=4 sw=4 tw=99 noet : - * ============================================================================= - * SourcePawn - * Copyright (C) 2004-2009 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 . - * - * 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 . - */ - -#ifndef _INCLUDE_SOURCEMOD_BASEFUNCTION_H_ -#define _INCLUDE_SOURCEMOD_BASEFUNCTION_H_ - -#include - -class BaseRuntime; - -using namespace SourcePawn; - -struct ParamInfo -{ - int flags; /* Copy-back flags */ - bool marked; /* Whether this is marked as being used */ - cell_t local_addr; /* Local address to free */ - cell_t *phys_addr; /* Physical address of our copy */ - cell_t *orig_addr; /* Original address to copy back to */ - ucell_t size; /* Size of array in bytes */ - struct - { - bool is_sz; /* is a string */ - int sz_flags; /* has sz flags */ - } str; -}; - -class CPlugin; -class JitFunction; - -class CFunction : public IPluginFunction -{ - friend class SourcePawnEngine; -public: - CFunction(BaseRuntime *pRuntime, - funcid_t fnid, - uint32_t pub_id); - ~CFunction(); -public: - virtual int PushCell(cell_t cell); - virtual int PushCellByRef(cell_t *cell, int flags); - virtual int PushFloat(float number); - virtual int PushFloatByRef(float *number, int flags); - virtual int PushArray(cell_t *inarray, unsigned int cells, int copyback); - virtual int PushString(const char *string); - virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags); - virtual int Execute(cell_t *result); - virtual void Cancel(); - virtual int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result); - virtual IPluginContext *GetParentContext(); - bool IsRunnable(); - funcid_t GetFunctionID(); - int Execute2(IPluginContext *ctx, cell_t *result); - int CallFunction2(IPluginContext *ctx, - const cell_t *params, - unsigned int num_params, - cell_t *result); - IPluginRuntime *GetParentRuntime(); -public: - const char *FullName() const { - return full_name_; - } - sp_public_t *Public() const { - return public_; - } -private: - int _PushString(const char *string, int sz_flags, int cp_flags, size_t len); - int SetError(int err); -private: - BaseRuntime *m_pRuntime; - cell_t m_params[SP_MAX_EXEC_PARAMS]; - ParamInfo m_info[SP_MAX_EXEC_PARAMS]; - unsigned int m_curparam; - int m_errorstate; - funcid_t m_FnId; - char *full_name_; - sp_public_t *public_; -}; - -#endif //_INCLUDE_SOURCEMOD_BASEFUNCTION_H_ diff --git a/sourcepawn/jit/version.rc b/sourcepawn/jit/version.rc deleted file mode 100644 index d79b5214..00000000 --- a/sourcepawn/jit/version.rc +++ /dev/null @@ -1,103 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -#include - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION SM_VERSION_FILE - PRODUCTVERSION SM_VERSION_FILE - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "Comments", "SourcePawn JIT" - VALUE "FileDescription", "SourcePawn JIT/Virtual Machine" - VALUE "FileVersion", SM_VERSION_STRING - VALUE "InternalName", "sourcemod" - VALUE "LegalCopyright", "Copyright (c) 2004-2008, AlliedModders LLC" - VALUE "OriginalFilename", "sourcepawn.jit.x86.dll" - VALUE "ProductName", "SourcePawn JIT" - VALUE "ProductVersion", SM_VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/sourcepawn/jit/watchdog_timer.cpp b/sourcepawn/jit/watchdog_timer.cpp deleted file mode 100644 index eb70c6ee..00000000 --- a/sourcepawn/jit/watchdog_timer.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -// -// This file is part of SourcePawn. -// -// SourcePawn is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// SourcePawn 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 SourcePawn. If not, see . -#include "watchdog_timer.h" -#include "x86/jit_x86.h" -#include - -WatchdogTimer g_WatchdogTimer; - -WatchdogTimer::WatchdogTimer() - : terminate_(false), - mainthread_(ke::GetCurrentThreadId()), - last_frame_id_(0), - second_timeout_(false), - timedout_(false) -{ -} - -WatchdogTimer::~WatchdogTimer() -{ - assert(!thread_); -} - -bool -WatchdogTimer::Initialize(size_t timeout_ms) -{ - if (thread_) - return false; - - timeout_ms_ = timeout_ms; - - thread_ = new ke::Thread(this, "SM Watchdog"); - if (!thread_->Succeeded()) - return false; - - return true; -} - -void -WatchdogTimer::Shutdown() -{ - if (terminate_ || !thread_) - return; - - { - ke::AutoLock lock(&cv_); - terminate_ = true; - cv_.Notify(); - } - thread_->Join(); - thread_ = NULL; -} - -void -WatchdogTimer::Run() -{ - ke::AutoLock lock(&cv_); - - // Initialize the frame id, so we don't have to wait longer on startup. - last_frame_id_ = g_Jit.FrameId(); - - while (!terminate_) { - ke::WaitResult rv = cv_.Wait(timeout_ms_ / 2); - if (terminate_) - return; - - if (rv == ke::Wait_Error) - return; - - if (rv != ke::Wait_Timeout) - continue; - - // We reached a timeout. If the current frame is not equal to the last - // frame, then we assume the server is still moving enough to process - // frames. We also make sure JIT code is actually on the stack, since - // our concept of frames won't move if JIT code is not running. - // - // Note that it's okay if these two race: it's just a heuristic, and - // worst case, we'll miss something that might have timed out but - // ended up resuming. - uintptr_t frame_id = g_Jit.FrameId(); - if (frame_id != last_frame_id_ || !g_Jit.RunningCode()) { - last_frame_id_ = frame_id; - second_timeout_ = false; - continue; - } - - // We woke up with the same frame. We might be timing out. Wait another - // time to see if so. - if (!second_timeout_) { - second_timeout_ = true; - continue; - } - - { - // Prevent the JIT from linking or destroying runtimes and functions. - ke::AutoLock lock(g_Jit.Mutex()); - - // Set the timeout notification bit. If this is detected before any patched - // JIT backedges are reached, the main thread will attempt to acquire the - // monitor lock, and block until we call Wait(). - timedout_ = true; - - // Patch all jumps. This can race with the main thread's execution since - // all code writes are 32-bit integer instruction operands, which are - // guaranteed to be atomic on x86. - g_Jit.PatchAllJumpsForTimeout(); - } - - // The JIT will be free to compile new functions while we wait, but it will - // see the timeout bit set above and immediately bail out. - cv_.Wait(); - - second_timeout_ = false; - - // Reset the last frame ID to something unlikely to be chosen again soon. - last_frame_id_--; - - // It's possible that Shutdown() raced with the timeout, and if so, we - // must leave now to prevent a deadlock. - if (terminate_) - return; - } -} - -bool -WatchdogTimer::NotifyTimeoutReceived() -{ - // We are guaranteed that the watchdog thread is waiting for our - // notification, and is therefore blocked. We take the JIT lock - // anyway for sanity. - { - ke::AutoLock lock(g_Jit.Mutex()); - g_Jit.UnpatchAllJumpsFromTimeout(); - } - - timedout_ = false; - - // Wake up the watchdog thread, it's okay to keep processing now. - ke::AutoLock lock(&cv_); - cv_.Notify(); - return false; -} - -bool -WatchdogTimer::HandleInterrupt() -{ - if (timedout_) - return NotifyTimeoutReceived(); - return true; -} diff --git a/sourcepawn/jit/watchdog_timer.h b/sourcepawn/jit/watchdog_timer.h deleted file mode 100644 index 45d57eea..00000000 --- a/sourcepawn/jit/watchdog_timer.h +++ /dev/null @@ -1,61 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -// -// This file is part of SourcePawn. -// -// SourcePawn is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// SourcePawn 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 SourcePawn. If not, see . -#ifndef _include_sourcepawn_watchdog_timer_posix_h_ -#define _include_sourcepawn_watchdog_timer_posix_h_ - -#include -#include -#include - -typedef bool (*WatchdogCallback)(); - -class WatchdogTimer : public ke::IRunnable -{ - public: - WatchdogTimer(); - ~WatchdogTimer(); - - bool Initialize(size_t timeout_ms); - void Shutdown(); - - // Called from main thread. - bool NotifyTimeoutReceived(); - bool HandleInterrupt(); - - private: - // Watchdog thread. - void Run(); - - private: - bool terminate_; - size_t timeout_ms_; - ke::ThreadId mainthread_; - - ke::AutoPtr thread_; - ke::ConditionVariable cv_; - - // Accessed only on the watchdog thread. - uintptr_t last_frame_id_; - bool second_timeout_; - - // Accessed only on the main thread. - bool timedout_; -}; - -extern WatchdogTimer g_WatchdogTimer; - -#endif // _include_sourcepawn_watchdog_timer_posix_h_ diff --git a/sourcepawn/jit/x86/jit_x86.cpp b/sourcepawn/jit/x86/jit_x86.cpp deleted file mode 100644 index 26e4098f..00000000 --- a/sourcepawn/jit/x86/jit_x86.cpp +++ /dev/null @@ -1,2111 +0,0 @@ -/** - * vim: set ts=2 sw=2 tw=99 et: - * ============================================================================= - * 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 . - * - * 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 . - * - * Version: $Id$ - */ - -#include -#include -#include -#include "jit_x86.h" -#include "../sp_vm_engine.h" -#include "../engine2.h" -#include "../BaseRuntime.h" -#include "../sp_vm_basecontext.h" -#include "watchdog_timer.h" -#include "interpreter.h" - -using namespace sp; -using namespace Knight; - -#if defined USE_UNGEN_OPCODES -#include "ungen_opcodes.h" -#endif - -#define __ masm. - -JITX86 g_Jit; -KeCodeCache *g_pCodeCache = NULL; -ISourcePawnEngine *engine = &g_engine1; - -static inline uint8_t * -LinkCode(AssemblerX86 &masm) -{ - if (masm.outOfMemory()) - return NULL; - - void *code = Knight::KE_AllocCode(g_pCodeCache, masm.length()); - if (!code) - return NULL; - - masm.emitToExecutableMemory(code); - return reinterpret_cast(code); -} - -static inline ConditionCode -OpToCondition(OPCODE op) -{ - switch (op) { - case OP_EQ: - case OP_JEQ: - return equal; - case OP_NEQ: - case OP_JNEQ: - return not_equal; - case OP_SLESS: - case OP_JSLESS: - return less; - case OP_SLEQ: - case OP_JSLEQ: - return less_equal; - case OP_SGRTR: - case OP_JSGRTR: - return greater; - case OP_SGEQ: - case OP_JSGEQ: - return greater_equal; - default: - assert(false); - return negative; - } -} - -struct array_creation_t -{ - const cell_t *dim_list; /* Dimension sizes */ - cell_t dim_count; /* Number of dimensions */ - cell_t *data_offs; /* Current offset AFTER the indirection vectors (data) */ - cell_t *base; /* array base */ -}; - -static cell_t -GenerateInnerArrayIndirectionVectors(array_creation_t *ar, int dim, cell_t cur_offs) -{ - cell_t write_offs = cur_offs; - cell_t *data_offs = ar->data_offs; - - cur_offs += ar->dim_list[dim]; - - // Dimension n-x where x > 2 will have sub-vectors. - // Otherwise, we just need to reference the data section. - if (ar->dim_count > 2 && dim < ar->dim_count - 2) { - // For each index at this dimension, write offstes to our sub-vectors. - // After we write one sub-vector, we generate its sub-vectors recursively. - // At the end, we're given the next offset we can use. - for (int i = 0; i < ar->dim_list[dim]; i++) { - ar->base[write_offs] = (cur_offs - write_offs) * sizeof(cell_t); - write_offs++; - cur_offs = GenerateInnerArrayIndirectionVectors(ar, dim + 1, cur_offs); - } - } else { - // In this section, there are no sub-vectors, we need to write offsets - // to the data. This is separate so the data stays in one big chunk. - // The data offset will increment by the size of the last dimension, - // because that is where the data is finally computed as. - for (int i = 0; i < ar->dim_list[dim]; i++) { - ar->base[write_offs] = (*data_offs - write_offs) * sizeof(cell_t); - write_offs++; - *data_offs = *data_offs + ar->dim_list[dim + 1]; - } - } - - return cur_offs; -} - -static cell_t -calc_indirection(const array_creation_t *ar, cell_t dim) -{ - cell_t size = ar->dim_list[dim]; - if (dim < ar->dim_count - 2) - size += ar->dim_list[dim] * calc_indirection(ar, dim + 1); - return size; -} - -static cell_t -GenerateArrayIndirectionVectors(cell_t *arraybase, cell_t dims[], cell_t _dimcount, bool autozero) -{ - array_creation_t ar; - cell_t data_offs; - - /* Reverse the dimensions */ - cell_t dim_list[sDIMEN_MAX]; - int cur_dim = 0; - for (int i = _dimcount - 1; i >= 0; i--) - dim_list[cur_dim++] = dims[i]; - - ar.base = arraybase; - ar.dim_list = dim_list; - ar.dim_count = _dimcount; - ar.data_offs = &data_offs; - - data_offs = calc_indirection(&ar, 0); - GenerateInnerArrayIndirectionVectors(&ar, 0, 0); - return data_offs; -} - -int -GenerateFullArray(BaseRuntime *rt, uint32_t argc, cell_t *argv, int autozero) -{ - sp_context_t *ctx = rt->GetBaseContext()->GetCtx(); - - // Calculate how many cells are needed. - if (argv[0] <= 0) - return SP_ERROR_ARRAY_TOO_BIG; - - uint32_t cells = argv[0]; - - for (uint32_t dim = 1; dim < argc; dim++) { - cell_t dimsize = argv[dim]; - if (dimsize <= 0) - return SP_ERROR_ARRAY_TOO_BIG; - if (!ke::IsUint32MultiplySafe(cells, dimsize)) - return SP_ERROR_ARRAY_TOO_BIG; - cells *= uint32_t(dimsize); - if (!ke::IsUint32AddSafe(cells, dimsize)) - return SP_ERROR_ARRAY_TOO_BIG; - cells += uint32_t(dimsize); - } - - if (!ke::IsUint32MultiplySafe(cells, 4)) - return SP_ERROR_ARRAY_TOO_BIG; - - uint32_t bytes = cells * 4; - if (!ke::IsUint32AddSafe(ctx->hp, bytes)) - return SP_ERROR_ARRAY_TOO_BIG; - - uint32_t new_hp = ctx->hp + bytes; - cell_t *dat_hp = reinterpret_cast(rt->plugin()->memory + new_hp); - - // argv, coincidentally, is STK. - if (dat_hp >= argv - STACK_MARGIN) - return SP_ERROR_HEAPLOW; - - if (int err = PushTracker(rt->GetBaseContext()->GetCtx(), bytes)) - return err; - - cell_t *base = reinterpret_cast(rt->plugin()->memory + ctx->hp); - cell_t offs = GenerateArrayIndirectionVectors(base, argv, argc, !!autozero); - assert(size_t(offs) == cells); - - argv[argc - 1] = ctx->hp; - ctx->hp = new_hp; - return SP_ERROR_NONE; -} - -#if !defined NDEBUG -static const char * -GetFunctionName(const sp_plugin_t *plugin, uint32_t offs) -{ - if (!plugin->debug.unpacked) { - uint32_t max, iter; - sp_fdbg_symbol_t *sym; - sp_fdbg_arraydim_t *arr; - uint8_t *cursor = (uint8_t *)(plugin->debug.symbols); - - max = plugin->debug.syms_num; - for (iter = 0; iter < max; iter++) { - sym = (sp_fdbg_symbol_t *)cursor; - - if (sym->ident == sp::IDENT_FUNCTION && sym->codestart <= offs && sym->codeend > offs) - return plugin->debug.stringbase + sym->name; - - if (sym->dimcount > 0) { - cursor += sizeof(sp_fdbg_symbol_t); - arr = (sp_fdbg_arraydim_t *)cursor; - cursor += sizeof(sp_fdbg_arraydim_t) * sym->dimcount; - continue; - } - - cursor += sizeof(sp_fdbg_symbol_t); - } - } else { - uint32_t max, iter; - sp_u_fdbg_symbol_t *sym; - sp_u_fdbg_arraydim_t *arr; - uint8_t *cursor = (uint8_t *)(plugin->debug.symbols); - - max = plugin->debug.syms_num; - for (iter = 0; iter < max; iter++) { - sym = (sp_u_fdbg_symbol_t *)cursor; - - if (sym->ident == sp::IDENT_FUNCTION && sym->codestart <= offs && sym->codeend > offs) - return plugin->debug.stringbase + sym->name; - - if (sym->dimcount > 0) { - cursor += sizeof(sp_u_fdbg_symbol_t); - arr = (sp_u_fdbg_arraydim_t *)cursor; - cursor += sizeof(sp_u_fdbg_arraydim_t) * sym->dimcount; - continue; - } - - cursor += sizeof(sp_u_fdbg_symbol_t); - } - } - - return NULL; -} -#endif - -static int -CompileFromThunk(BaseRuntime *runtime, cell_t pcode_offs, void **addrp, char *pc) -{ - // If the watchdog timer has declared a timeout, we must process it now, - // and possibly refuse to compile, since otherwise we will compile a - // function that is not patched for timeouts. - if (!g_WatchdogTimer.HandleInterrupt()) - return SP_ERROR_TIMEOUT; - - JitFunction *fn = runtime->GetJittedFunctionByOffset(pcode_offs); - if (!fn) { - int err; - fn = g_Jit.CompileFunction(runtime, pcode_offs, &err); - if (!fn) - return err; - } - -#if defined JIT_SPEW - g_engine1.GetDebugHook()->OnDebugSpew( - "Patching thunk to %s::%s\n", - runtime->plugin()->name, - GetFunctionName(runtime->plugin(), pcode_offs)); -#endif - - *addrp = fn->GetEntryAddress(); - - /* Right now, we always keep the code RWE */ - *(intptr_t *)(pc - 4) = intptr_t(fn->GetEntryAddress()) - intptr_t(pc); - return SP_ERROR_NONE; -} - -Compiler::Compiler(BaseRuntime *rt, cell_t pcode_offs) - : rt_(rt), - plugin_(rt->plugin()), - error_(SP_ERROR_NONE), - pcode_start_(pcode_offs), - code_start_(reinterpret_cast(plugin_->pcode + pcode_start_)), - cip_(code_start_), - code_end_(reinterpret_cast(plugin_->pcode + plugin_->pcode_size)) -{ - size_t nmaxops = plugin_->pcode_size / sizeof(cell_t) + 1; - jump_map_ = new Label[nmaxops]; -} - -Compiler::~Compiler() -{ - delete [] jump_map_; -} - -JitFunction * -Compiler::emit(int *errp) -{ - if (cip_ >= code_end_ || *cip_ != OP_PROC) { - *errp = SP_ERROR_INVALID_INSTRUCTION; - return NULL; - } - -#if defined JIT_SPEW - g_engine1.GetDebugHook()->OnDebugSpew( - "Compiling function %s::%s\n", - plugin_->name, - GetFunctionName(plugin_, pcode_start_)); - - SpewOpcode(plugin_, code_start_, cip_); -#endif - - cell_t *codeseg = reinterpret_cast(plugin_->pcode); - - cip_++; - if (!emitOp(OP_PROC)) { - *errp = (error_ == SP_ERROR_NONE) ? SP_ERROR_OUT_OF_MEMORY : error_; - return NULL; - } - - while (cip_ < code_end_) { - // If we reach the end of this function, or the beginning of a new - // procedure, then stop. - if (*cip_ == OP_PROC || *cip_ == OP_ENDPROC) - break; - -#if defined JIT_SPEW - SpewOpcode(plugin_, code_start_, cip_); -#endif - - // We assume every instruction is a jump target, so before emitting - // an opcode, we bind its corresponding label. - __ bind(&jump_map_[cip_ - codeseg]); - - OPCODE op = (OPCODE)readCell(); - if (!emitOp(op) || error_ != SP_ERROR_NONE) { - *errp = (error_ == SP_ERROR_NONE) ? SP_ERROR_OUT_OF_MEMORY : error_; - return NULL; - } - } - - emitCallThunks(); - emitErrorPaths(); - - uint8_t *code = LinkCode(masm); - if (!code) { - *errp = SP_ERROR_OUT_OF_MEMORY; - return NULL; - } - - LoopEdge *edges = new LoopEdge[backward_jumps_.length()]; - for (size_t i = 0; i < backward_jumps_.length(); i++) { - edges[i].offset = backward_jumps_[i]; - edges[i].disp32 = *reinterpret_cast(code + edges[i].offset - 4); - } - - return new JitFunction(code, pcode_start_, edges, backward_jumps_.length()); -} - -bool -Compiler::emitOp(OPCODE op) -{ - switch (op) { - case OP_MOVE_PRI: - __ movl(pri, alt); - break; - - case OP_MOVE_ALT: - __ movl(alt, pri); - break; - - case OP_XCHG: - __ xchgl(pri, alt); - break; - - case OP_ZERO: - { - cell_t offset = readCell(); - __ movl(Operand(dat, offset), 0); - break; - } - - case OP_ZERO_S: - { - cell_t offset = readCell(); - __ movl(Operand(frm, offset), 0); - break; - } - - case OP_PUSH_PRI: - case OP_PUSH_ALT: - { - Register reg = (op == OP_PUSH_PRI) ? pri : alt; - __ movl(Operand(stk, -4), reg); - __ subl(stk, 4); - break; - } - - case OP_PUSH_C: - case OP_PUSH2_C: - case OP_PUSH3_C: - case OP_PUSH4_C: - case OP_PUSH5_C: - { - int n = 1; - if (op >= OP_PUSH2_C) - n = ((op - OP_PUSH2_C) / 4) + 2; - - int i = 1; - do { - cell_t val = readCell(); - __ movl(Operand(stk, -(4 * i)), val); - } while (i++ < n); - __ subl(stk, 4 * n); - break; - } - - case OP_PUSH_ADR: - case OP_PUSH2_ADR: - case OP_PUSH3_ADR: - case OP_PUSH4_ADR: - case OP_PUSH5_ADR: - { - int n = 1; - if (op >= OP_PUSH2_ADR) - n = ((op - OP_PUSH2_ADR) / 4) + 2; - - int i = 1; - - // We temporarily relocate FRM to be a local address instead of an - // absolute address. - __ subl(frm, dat); - do { - cell_t offset = readCell(); - __ lea(tmp, Operand(frm, offset)); - __ movl(Operand(stk, -(4 * i)), tmp); - } while (i++ < n); - __ subl(stk, 4 * n); - __ addl(frm, dat); - break; - } - - case OP_PUSH_S: - case OP_PUSH2_S: - case OP_PUSH3_S: - case OP_PUSH4_S: - case OP_PUSH5_S: - { - int n = 1; - if (op >= OP_PUSH2_S) - n = ((op - OP_PUSH2_S) / 4) + 2; - - int i = 1; - do { - cell_t offset = readCell(); - __ movl(tmp, Operand(frm, offset)); - __ movl(Operand(stk, -(4 * i)), tmp); - } while (i++ < n); - __ subl(stk, 4 * n); - break; - } - - case OP_PUSH: - case OP_PUSH2: - case OP_PUSH3: - case OP_PUSH4: - case OP_PUSH5: - { - int n = 1; - if (op >= OP_PUSH2) - n = ((op - OP_PUSH2) / 4) + 2; - - int i = 1; - do { - cell_t offset = readCell(); - __ movl(tmp, Operand(dat, offset)); - __ movl(Operand(stk, -(4 * i)), tmp); - } while (i++ < n); - __ subl(stk, 4 * n); - break; - } - - case OP_ZERO_PRI: - __ xorl(pri, pri); - break; - - case OP_ZERO_ALT: - __ xorl(alt, alt); - break; - - case OP_ADD: - __ addl(pri, alt); - break; - - case OP_SUB: - __ subl(pri, alt); - break; - - case OP_SUB_ALT: - __ movl(tmp, alt); - __ subl(tmp, pri); - __ movl(pri, tmp); - break; - - case OP_PROC: - // Push the old frame onto the stack. - __ movl(tmp, Operand(frmAddr())); - __ movl(Operand(stk, -4), tmp); - __ subl(stk, 8); // extra unused slot for non-existant CIP - - // Get and store the new frame. - __ movl(tmp, stk); - __ movl(frm, stk); - __ subl(tmp, dat); - __ movl(Operand(frmAddr()), tmp); - - // Align the stack to 16-bytes (each call adds 4 bytes). - __ subl(esp, 12); - break; - - case OP_IDXADDR_B: - { - cell_t val = readCell(); - __ shll(pri, val); - __ addl(pri, alt); - break; - } - - case OP_SHL: - __ movl(ecx, alt); - __ shll_cl(pri); - break; - - case OP_SHR: - __ movl(ecx, alt); - __ shrl_cl(pri); - break; - - case OP_SSHR: - __ movl(ecx, alt); - __ sarl_cl(pri); - break; - - case OP_SHL_C_PRI: - case OP_SHL_C_ALT: - { - Register reg = (op == OP_SHL_C_PRI) ? pri : alt; - cell_t val = readCell(); - __ shll(reg, val); - break; - } - - case OP_SHR_C_PRI: - case OP_SHR_C_ALT: - { - Register reg = (op == OP_SHR_C_PRI) ? pri : alt; - cell_t val = readCell(); - __ shrl(reg, val); - break; - } - - case OP_SMUL: - __ imull(pri, alt); - break; - - case OP_NOT: - __ testl(eax, eax); - __ movl(eax, 0); - __ set(zero, r8_al); - break; - - case OP_NEG: - __ negl(eax); - break; - - case OP_XOR: - __ xorl(pri, alt); - break; - - case OP_OR: - __ orl(pri, alt); - break; - - case OP_AND: - __ andl(pri, alt); - break; - - case OP_INVERT: - __ notl(pri); - break; - - case OP_ADD_C: - { - cell_t val = readCell(); - __ addl(pri, val); - break; - } - - case OP_SMUL_C: - { - cell_t val = readCell(); - __ imull(pri, pri, val); - break; - } - - case OP_EQ: - case OP_NEQ: - case OP_SLESS: - case OP_SLEQ: - case OP_SGRTR: - case OP_SGEQ: - { - ConditionCode cc = OpToCondition(op); - __ cmpl(pri, alt); - __ movl(pri, 0); - __ set(cc, r8_al); - break; - } - - case OP_EQ_C_PRI: - case OP_EQ_C_ALT: - { - Register reg = (op == OP_EQ_C_PRI) ? pri : alt; - cell_t val = readCell(); - __ cmpl(reg, val); - __ movl(pri, 0); - __ set(equal, r8_al); - break; - } - - case OP_INC_PRI: - case OP_INC_ALT: - { - Register reg = (OP_INC_PRI) ? pri : alt; - __ addl(reg, 1); - break; - } - - case OP_INC: - case OP_INC_S: - { - Register base = (op == OP_INC) ? dat : frm; - cell_t offset = readCell(); - __ addl(Operand(base, offset), 1); - break; - } - - case OP_INC_I: - __ addl(Operand(dat, pri, NoScale), 1); - break; - - case OP_DEC_PRI: - case OP_DEC_ALT: - { - Register reg = (op == OP_DEC_PRI) ? pri : alt; - __ subl(reg, 1); - break; - } - - case OP_DEC: - case OP_DEC_S: - { - Register base = (op == OP_DEC) ? dat : frm; - cell_t offset = readCell(); - __ subl(Operand(base, offset), 1); - break; - } - - case OP_DEC_I: - __ subl(Operand(dat, pri, NoScale), 1); - break; - - case OP_LOAD_PRI: - case OP_LOAD_ALT: - { - Register reg = (op == OP_LOAD_PRI) ? pri : alt; - cell_t offset = readCell(); - __ movl(reg, Operand(dat, offset)); - break; - } - - case OP_LOAD_BOTH: - { - cell_t offs1 = readCell(); - cell_t offs2 = readCell(); - __ movl(pri, Operand(dat, offs1)); - __ movl(alt, Operand(dat, offs2)); - break; - } - - case OP_LOAD_S_PRI: - case OP_LOAD_S_ALT: - { - Register reg = (op == OP_LOAD_S_PRI) ? pri : alt; - cell_t offset = readCell(); - __ movl(reg, Operand(frm, offset)); - break; - } - - case OP_LOAD_S_BOTH: - { - cell_t offs1 = readCell(); - cell_t offs2 = readCell(); - __ movl(pri, Operand(frm, offs1)); - __ movl(alt, Operand(frm, offs2)); - break; - } - - case OP_LREF_S_PRI: - case OP_LREF_S_ALT: - { - Register reg = (op == OP_LREF_S_PRI) ? pri : alt; - cell_t offset = readCell(); - __ movl(reg, Operand(frm, offset)); - __ movl(reg, Operand(dat, reg, NoScale)); - break; - } - - case OP_CONST_PRI: - case OP_CONST_ALT: - { - Register reg = (op == OP_CONST_PRI) ? pri : alt; - cell_t val = readCell(); - __ movl(reg, val); - break; - } - - case OP_ADDR_PRI: - case OP_ADDR_ALT: - { - Register reg = (op == OP_ADDR_PRI) ? pri : alt; - cell_t offset = readCell(); - __ movl(reg, Operand(frmAddr())); - __ addl(reg, offset); - break; - } - - case OP_STOR_PRI: - case OP_STOR_ALT: - { - Register reg = (op == OP_STOR_PRI) ? pri : alt; - cell_t offset = readCell(); - __ movl(Operand(dat, offset), reg); - break; - } - - case OP_STOR_S_PRI: - case OP_STOR_S_ALT: - { - Register reg = (op == OP_STOR_S_PRI) ? pri : alt; - cell_t offset = readCell(); - __ movl(Operand(frm, offset), reg); - break; - } - - case OP_IDXADDR: - __ lea(pri, Operand(alt, pri, ScaleFour)); - break; - - case OP_SREF_S_PRI: - case OP_SREF_S_ALT: - { - Register reg = (op == OP_SREF_S_PRI) ? pri : alt; - cell_t offset = readCell(); - __ movl(tmp, Operand(frm, offset)); - __ movl(Operand(dat, tmp, NoScale), reg); - break; - } - - case OP_POP_PRI: - case OP_POP_ALT: - { - Register reg = (op == OP_POP_PRI) ? pri : alt; - __ movl(reg, Operand(stk, 0)); - __ addl(stk, 4); - break; - } - - case OP_SWAP_PRI: - case OP_SWAP_ALT: - { - Register reg = (op == OP_SWAP_PRI) ? pri : alt; - __ movl(tmp, Operand(stk, 0)); - __ movl(Operand(stk, 0), reg); - __ movl(reg, tmp); - break; - } - - case OP_LIDX: - __ lea(pri, Operand(alt, pri, ScaleFour)); - __ movl(pri, Operand(dat, pri, NoScale)); - break; - - case OP_LIDX_B: - { - cell_t val = readCell(); - if (val >= 0 && val <= 3) { - __ lea(pri, Operand(alt, pri, Scale(val))); - } else { - __ shll(pri, val); - __ addl(pri, alt); - } - emitCheckAddress(pri); - __ movl(pri, Operand(dat, pri, NoScale)); - break; - } - - case OP_CONST: - case OP_CONST_S: - { - Register base = (op == OP_CONST) ? dat : frm; - cell_t offset = readCell(); - cell_t val = readCell(); - __ movl(Operand(base, offset), val); - break; - } - - case OP_LOAD_I: - emitCheckAddress(pri); - __ movl(pri, Operand(dat, pri, NoScale)); - break; - - case OP_STOR_I: - emitCheckAddress(alt); - __ movl(Operand(dat, alt, NoScale), pri); - break; - - case OP_SDIV: - case OP_SDIV_ALT: - { - Register dividend = (op == OP_SDIV) ? pri : alt; - Register divisor = (op == OP_SDIV) ? alt : pri; - - // Guard against divide-by-zero. - __ testl(divisor, divisor); - __ j(zero, &error_divide_by_zero_); - - // A more subtle case; -INT_MIN / -1 yields an overflow exception. - Label ok; - __ cmpl(divisor, -1); - __ j(not_equal, &ok); - __ cmpl(dividend, 0x80000000); - __ j(equal, &error_integer_overflow_); - __ bind(&ok); - - // Now we can actually perform the divide. - __ movl(tmp, divisor); - if (op == OP_SDIV) - __ movl(edx, dividend); - else - __ movl(eax, dividend); - __ sarl(edx, 31); - __ idivl(tmp); - break; - } - - case OP_LODB_I: - { - cell_t val = readCell(); - emitCheckAddress(pri); - __ movl(pri, Operand(dat, pri, NoScale)); - if (val == 1) - __ andl(pri, 0xff); - else if (val == 2) - __ andl(pri, 0xffff); - break; - } - - case OP_STRB_I: - { - cell_t val = readCell(); - emitCheckAddress(alt); - if (val == 1) - __ movb(Operand(dat, alt, NoScale), pri); - else if (val == 2) - __ movw(Operand(dat, alt, NoScale), pri); - else if (val == 4) - __ movl(Operand(dat, alt, NoScale), pri); - break; - } - - case OP_RETN: - { - // Restore the old frame pointer. - __ movl(frm, Operand(stk, 4)); // get the old frm - __ addl(stk, 8); // pop stack - __ movl(Operand(frmAddr()), frm); // store back old frm - __ addl(frm, dat); // relocate - - // Remove parameters. - __ movl(tmp, Operand(stk, 0)); - __ lea(stk, Operand(stk, tmp, ScaleFour, 4)); - __ addl(esp, 12); - __ ret(); - break; - } - - case OP_MOVS: - { - cell_t val = readCell(); - unsigned dwords = val / 4; - unsigned bytes = val % 4; - - __ cld(); - __ push(esi); - __ push(edi); - // Note: set edi first, since we need esi. - __ lea(edi, Operand(dat, alt, NoScale)); - __ lea(esi, Operand(dat, pri, NoScale)); - if (dwords) { - __ movl(ecx, dwords); - __ rep_movsd(); - } - if (bytes) { - __ movl(ecx, bytes); - __ rep_movsb(); - } - __ pop(edi); - __ pop(esi); - break; - } - - case OP_FILL: - { - // eax/pri is used implicitly. - unsigned dwords = readCell() / 4; - __ push(edi); - __ lea(edi, Operand(dat, alt, NoScale)); - __ movl(ecx, dwords); - __ cld(); - __ rep_stosd(); - __ pop(edi); - break; - } - - case OP_STRADJUST_PRI: - __ addl(pri, 4); - __ sarl(pri, 2); - break; - - case OP_FABS: - __ movl(pri, Operand(stk, 0)); - __ andl(pri, 0x7fffffff); - __ addl(stk, 4); - break; - - case OP_FLOAT: - if (MacroAssemblerX86::Features().sse2) { - __ cvtsi2ss(xmm0, Operand(edi, 0)); - __ movd(pri, xmm0); - } else { - __ fild32(Operand(edi, 0)); - __ subl(esp, 4); - __ fstp32(Operand(esp, 0)); - __ pop(pri); - } - __ addl(stk, 4); - break; - - case OP_FLOATADD: - case OP_FLOATSUB: - case OP_FLOATMUL: - case OP_FLOATDIV: - if (MacroAssemblerX86::Features().sse2) { - __ movss(xmm0, Operand(stk, 0)); - if (op == OP_FLOATADD) - __ addss(xmm0, Operand(stk, 4)); - else if (op == OP_FLOATSUB) - __ subss(xmm0, Operand(stk, 4)); - else if (op == OP_FLOATMUL) - __ mulss(xmm0, Operand(stk, 4)); - else if (op == OP_FLOATDIV) - __ divss(xmm0, Operand(stk, 4)); - __ movd(pri, xmm0); - } else { - __ subl(esp, 4); - __ fld32(Operand(stk, 0)); - - if (op == OP_FLOATADD) - __ fadd32(Operand(stk, 4)); - else if (op == OP_FLOATSUB) - __ fsub32(Operand(stk, 4)); - else if (op == OP_FLOATMUL) - __ fmul32(Operand(stk, 4)); - else if (op == OP_FLOATDIV) - __ fdiv32(Operand(stk, 4)); - - __ fstp32(Operand(esp, 0)); - __ pop(pri); - } - __ addl(stk, 8); - break; - - case OP_RND_TO_NEAREST: - { - if (MacroAssemblerX86::Features().sse) { - // Assume no one is touching MXCSR. - __ cvtss2si(pri, Operand(stk, 0)); - } else { - static float kRoundToNearest = 0.5f; - // From http://wurstcaptures.untergrund.net/assembler_tricks.html#fastfloorf - __ fld32(Operand(stk, 0)); - __ fadd32(st0, st0); - __ fadd32(Operand(ExternalAddress(&kRoundToNearest))); - __ subl(esp, 4); - __ fistp32(Operand(esp, 0)); - __ pop(pri); - __ sarl(pri, 1); - } - __ addl(stk, 4); - break; - } - - case OP_RND_TO_CEIL: - { - static float kRoundToCeil = -0.5f; - // From http://wurstcaptures.untergrund.net/assembler_tricks.html#fastfloorf - __ fld32(Operand(stk, 0)); - __ fadd32(st0, st0); - __ fsubr32(Operand(ExternalAddress(&kRoundToCeil))); - __ subl(esp, 4); - __ fistp32(Operand(esp, 0)); - __ pop(pri); - __ sarl(pri, 1); - __ negl(pri); - __ addl(stk, 4); - break; - } - - case OP_RND_TO_ZERO: - if (MacroAssemblerX86::Features().sse) { - __ cvttss2si(pri, Operand(stk, 0)); - } else { - __ fld32(Operand(stk, 0)); - __ subl(esp, 8); - __ fstcw(Operand(esp, 4)); - __ movl(Operand(esp, 0), 0xfff); - __ fldcw(Operand(esp, 0)); - __ fistp32(Operand(esp, 0)); - __ pop(pri); - __ fldcw(Operand(esp, 0)); - __ addl(esp, 4); - } - __ addl(stk, 4); - break; - - case OP_RND_TO_FLOOR: - __ fld32(Operand(stk, 0)); - __ subl(esp, 8); - __ fstcw(Operand(esp, 4)); - __ movl(Operand(esp, 0), 0x7ff); - __ fldcw(Operand(esp, 0)); - __ fistp32(Operand(esp, 0)); - __ pop(eax); - __ fldcw(Operand(esp, 0)); - __ addl(esp, 4); - __ addl(stk, 4); - break; - - // This is the old float cmp, which returns ordered results. In newly - // compiled code it should not be used or generated. - // - // Note that the checks here are inverted: the test is |rhs OP lhs|. - case OP_FLOATCMP: - { - Label bl, ab, done; - if (MacroAssemblerX86::Features().sse) { - __ movss(xmm0, Operand(stk, 4)); - __ ucomiss(Operand(stk, 0), xmm0); - } else { - __ fld32(Operand(stk, 0)); - __ fld32(Operand(stk, 4)); - __ fucomip(st1); - __ fstp(st0); - } - __ j(above, &ab); - __ j(below, &bl); - __ xorl(pri, pri); - __ jmp(&done); - __ bind(&ab); - __ movl(pri, -1); - __ jmp(&done); - __ bind(&bl); - __ movl(pri, 1); - __ bind(&done); - __ addl(stk, 8); - break; - } - - case OP_FLOAT_GT: - emitFloatCmp(above); - break; - - case OP_FLOAT_GE: - emitFloatCmp(above_equal); - break; - - case OP_FLOAT_LE: - emitFloatCmp(below_equal); - break; - - case OP_FLOAT_LT: - emitFloatCmp(below); - break; - - case OP_FLOAT_EQ: - emitFloatCmp(equal); - break; - - case OP_FLOAT_NE: - emitFloatCmp(not_equal); - break; - - case OP_FLOAT_NOT: - { - if (MacroAssemblerX86::Features().sse) { - __ xorps(xmm0, xmm0); - __ ucomiss(Operand(stk, 0), xmm0); - } else { - __ fld32(Operand(stk, 0)); - __ fldz(); - __ fucomip(st1); - __ fstp(st0); - } - - // See emitFloatCmp() - this is a shorter version. - Label done; - __ movl(eax, 1); - __ j(parity, &done); - __ set(zero, r8_al); - __ bind(&done); - - __ addl(stk, 4); - break; - } - - case OP_STACK: - { - cell_t amount = readCell(); - __ addl(stk, amount); - - if (amount > 0) { - // Check if the stack went beyond the stack top - usually a compiler error. - __ cmpl(stk, intptr_t(plugin_->memory + plugin_->mem_size)); - __ j(not_below, &error_stack_min_); - } else { - // Check if the stack is going to collide with the heap. - __ movl(tmp, Operand(hpAddr())); - __ lea(tmp, Operand(dat, ecx, NoScale, STACK_MARGIN)); - __ cmpl(stk, tmp); - __ j(below, &error_stack_low_); - } - break; - } - - case OP_HEAP: - { - cell_t amount = readCell(); - __ movl(alt, Operand(hpAddr())); - __ addl(Operand(hpAddr()), amount); - - if (amount < 0) { - __ cmpl(Operand(hpAddr()), plugin_->data_size); - __ j(below, &error_heap_min_); - } else { - __ movl(tmp, Operand(hpAddr())); - __ lea(tmp, Operand(dat, ecx, NoScale, STACK_MARGIN)); - __ cmpl(tmp, stk); - __ j(above, &error_heap_low_); - } - break; - } - - case OP_JUMP: - { - Label *target = labelAt(readCell()); - if (!target) - return false; - if (target->bound()) { - __ jmp32(target); - backward_jumps_.append(masm.pc()); - } else { - __ jmp(target); - } - break; - } - - case OP_JZER: - case OP_JNZ: - { - ConditionCode cc = (op == OP_JZER) ? zero : not_zero; - Label *target = labelAt(readCell()); - if (!target) - return false; - __ testl(pri, pri); - if (target->bound()) { - __ j32(cc, target); - backward_jumps_.append(masm.pc()); - } else { - __ j(cc, target); - } - break; - } - - case OP_JEQ: - case OP_JNEQ: - case OP_JSLESS: - case OP_JSLEQ: - case OP_JSGRTR: - case OP_JSGEQ: - { - Label *target = labelAt(readCell()); - if (!target) - return false; - ConditionCode cc = OpToCondition(op); - __ cmpl(pri, alt); - if (target->bound()) { - __ j32(cc, target); - backward_jumps_.append(masm.pc()); - } else { - __ j(cc, target); - } - break; - } - - case OP_TRACKER_PUSH_C: - { - cell_t amount = readCell(); - - __ push(pri); - __ push(alt); - - __ push(amount * 4); - __ push(intptr_t(rt_->GetBaseContext()->GetCtx())); - __ call(ExternalAddress((void *)PushTracker)); - __ addl(esp, 8); - __ testl(eax, eax); - __ j(not_zero, &extern_error_); - - __ pop(alt); - __ pop(pri); - break; - } - - case OP_TRACKER_POP_SETHEAP: - { - // Save registers. - __ push(pri); - __ push(alt); - - // Get the context pointer and call the sanity checker. - __ push(intptr_t(rt_)); - __ call(ExternalAddress((void *)PopTrackerAndSetHeap)); - __ addl(esp, 4); - __ testl(eax, eax); - __ j(not_zero, &extern_error_); - - __ pop(alt); - __ pop(pri); - break; - } - - case OP_BREAK: - { - cell_t cip = uintptr_t(cip_ - 1) - uintptr_t(plugin_->pcode); - __ movl(Operand(cipAddr()), cip); - break; - } - - case OP_HALT: - __ align(16); - __ movl(tmp, intptr_t(rt_->GetBaseContext()->GetCtx())); - __ movl(Operand(tmp, offsetof(sp_context_t, rval)), pri); - __ movl(pri, readCell()); - __ jmp(&extern_error_); - break; - - case OP_BOUNDS: - { - cell_t value = readCell(); - __ cmpl(eax, value); - __ j(above, &error_bounds_); - break; - } - - case OP_GENARRAY: - case OP_GENARRAY_Z: - emitGenArray(op == OP_GENARRAY_Z); - break; - - case OP_CALL: - if (!emitCall()) - return false; - break; - - case OP_SYSREQ_C: - case OP_SYSREQ_N: - if (!emitNativeCall(op)) - return false; - break; - - case OP_SWITCH: - if (!emitSwitch()) - return false; - break; - - case OP_CASETBL: - { - size_t ncases = readCell(); - - // Two cells per case, and one extra cell for the default address. - cip_ += (ncases * 2) + 1; - break; - } - - case OP_NOP: - break; - - default: - error_ = SP_ERROR_INVALID_INSTRUCTION; - return false; - } - - return true; -} - -Label * -Compiler::labelAt(size_t offset) -{ - if (offset % 4 != 0 || - offset > plugin_->pcode_size || - offset <= pcode_start_) - { - // If the jump target is misaligned, or out of pcode bounds, or is an - // address out of the function bounds, we abort. Unfortunately we can't - // test beyond the end of the function since we don't have a precursor - // pass (yet). - error_ = SP_ERROR_INSTRUCTION_PARAM; - return NULL; - } - - return &jump_map_[offset / sizeof(cell_t)]; -} - -void -Compiler::emitCheckAddress(Register reg) -{ - // Check if we're in memory bounds. - __ cmpl(reg, plugin_->mem_size); - __ j(not_below, &error_memaccess_); - - // Check if we're in the invalid region between hp and sp. - Label done; - __ cmpl(reg, Operand(hpAddr())); - __ j(below, &done); - __ lea(tmp, Operand(dat, reg, NoScale)); - __ cmpl(tmp, stk); - __ j(below, &error_memaccess_); - __ bind(&done); -} - -void -Compiler::emitGenArray(bool autozero) -{ - cell_t val = readCell(); - if (val == 1) - { - // flat array; we can generate this without indirection tables. - // Note that we can overwrite ALT because technically STACK should be destroying ALT - __ movl(alt, Operand(hpAddr())); - __ movl(tmp, Operand(stk, 0)); - __ movl(Operand(stk, 0), alt); // store base of the array into the stack. - __ lea(alt, Operand(alt, tmp, ScaleFour)); - __ movl(Operand(hpAddr()), alt); - __ addl(alt, dat); - __ cmpl(alt, stk); - __ j(not_below, &error_heap_low_); - - __ shll(tmp, 2); - __ push(tmp); - __ push(intptr_t(rt_->GetBaseContext()->GetCtx())); - __ call(ExternalAddress((void *)PushTracker)); - __ addl(esp, 4); - __ pop(tmp); - __ shrl(tmp, 2); - __ testl(eax, eax); - __ j(not_zero, &extern_error_); - - if (autozero) { - // Note - tmp is ecx and still intact. - __ push(eax); - __ push(edi); - __ xorl(eax, eax); - __ movl(edi, Operand(stk, 0)); - __ addl(edi, dat); - __ cld(); - __ rep_stosd(); - __ pop(edi); - __ pop(eax); - } - } else { - __ push(pri); - - // int GenerateArray(sp_plugin_t, vars[], uint32_t, cell_t *, int, unsigned *); - __ push(autozero ? 1 : 0); - __ push(stk); - __ push(val); - __ push(intptr_t(rt_)); - __ call(ExternalAddress((void *)GenerateFullArray)); - __ addl(esp, 4 * sizeof(void *)); - - // restore pri to tmp - __ pop(tmp); - - __ testl(eax, eax); - __ j(not_zero, &extern_error_); - - // Move tmp back to pri, remove pushed args. - __ movl(pri, tmp); - __ addl(stk, (val - 1) * 4); - } -} - -bool -Compiler::emitCall() -{ - cell_t offset = readCell(); - - // If this offset looks crappy, i.e. not aligned or out of bounds, we just - // abort. - if (offset % 4 != 0 || uint32_t(offset) >= plugin_->pcode_size) { - error_ = SP_ERROR_INSTRUCTION_PARAM; - return false; - } - - // eax = context - // ecx = rp - __ movl(eax, intptr_t(rt_->GetBaseContext()->GetCtx())); - __ movl(ecx, Operand(eax, offsetof(sp_context_t, rp))); - - // Check if the return stack is used up. - __ cmpl(ecx, SP_MAX_RETURN_STACK); - __ j(not_below, &error_stack_low_); - - // Add to the return stack. - uintptr_t cip = uintptr_t(cip_ - 2) - uintptr_t(plugin_->pcode); - __ movl(Operand(eax, ecx, ScaleFour, offsetof(sp_context_t, rstk_cips)), cip); - - // Increment the return stack pointer. - __ addl(Operand(eax, offsetof(sp_context_t, rp)), 1); - - // Store the CIP of the function we're about to call. - __ movl(Operand(cipAddr()), offset); - - JitFunction *fun = rt_->GetJittedFunctionByOffset(offset); - if (!fun) { - // Need to emit a delayed thunk. - CallThunk *thunk = new CallThunk(offset); - __ call(&thunk->call); - if (!thunks_.append(thunk)) - return false; - } else { - // Function is already emitted, we can do a direct call. - __ call(ExternalAddress(fun->GetEntryAddress())); - } - - // Restore the last cip. - __ movl(Operand(cipAddr()), cip); - - // Mark us as leaving the last frame. - __ movl(tmp, intptr_t(rt_->GetBaseContext()->GetCtx())); - __ subl(Operand(tmp, offsetof(sp_context_t, rp)), 1); - return true; -} - -void -Compiler::emitCallThunks() -{ - for (size_t i = 0; i < thunks_.length(); i++) { - CallThunk *thunk = thunks_[i]; - - Label error; - __ bind(&thunk->call); - // Huge hack - get the return address, since that is the call that we - // need to patch. - __ movl(eax, Operand(esp, 0)); - - // We need to push 4 arguments, and one of them will need an extra word - // on the stack. Allocate a big block so we're aligned, subtracting - // 4 because we got here via a call. - static const size_t kStackNeeded = 5 * sizeof(void *); - static const size_t kStackReserve = ke::Align(kStackNeeded, 16) - sizeof(void *); - __ subl(esp, kStackReserve); - - // Set arguments. - __ movl(Operand(esp, 3 * sizeof(void *)), eax); - __ lea(edx, Operand(esp, 4 * sizeof(void *))); - __ movl(Operand(esp, 2 * sizeof(void *)), edx); - __ movl(Operand(esp, 1 * sizeof(void *)), intptr_t(thunk->pcode_offset)); - __ movl(Operand(esp, 0 * sizeof(void *)), intptr_t(rt_)); - - __ call(ExternalAddress((void *)CompileFromThunk)); - __ movl(edx, Operand(esp, 4 * sizeof(void *))); - __ addl(esp, kStackReserve); - __ testl(eax, eax); - __ j(not_zero, &error); - __ jmp(edx); - - __ bind(&error); - __ movl(Operand(cipAddr()), thunk->pcode_offset); - __ jmp(g_Jit.GetUniversalReturn()); - } -} - -cell_t -Compiler::readCell() -{ - if (cip_ >= code_end_) { - error_= SP_ERROR_INVALID_INSTRUCTION; - return 0; - } - return *cip_++; -} - -bool -Compiler::emitNativeCall(OPCODE op) -{ - uint32_t native_index = readCell(); - - if (native_index >= plugin_->num_natives) { - error_ = SP_ERROR_INSTRUCTION_PARAM; - return false; - } - - uint32_t num_params; - if (op == OP_SYSREQ_N) { - num_params = readCell(); - - // See if we can get a replacement opcode. If we can, then recursively - // call emitOp() to generate it. Note: it's important that we do this - // before generating any code for the SYSREQ.N. - unsigned replacement = rt_->GetNativeReplacement(native_index); - if (replacement != OP_NOP) - return emitOp((OPCODE)replacement); - - // Store the number of parameters. - __ movl(Operand(stk, -4), num_params); - __ subl(stk, 4); - } - - // Save registers. - __ push(edx); - - // Push the last parameter for the C++ function. - __ push(stk); - - // Relocate our absolute stk to be dat-relative, and update the context's - // view. - __ movl(eax, intptr_t(rt_->GetBaseContext()->GetCtx())); - __ subl(stk, dat); - __ movl(Operand(eax, offsetof(sp_context_t, sp)), stk); - - __ movl(Operand(eax, offsetof(sp_context_t, n_idx)), native_index); - - sp_native_t *native = rt_->GetNativeByIndex(native_index); - if ((native->status != SP_NATIVE_BOUND) || - (native->flags & (SP_NTVFLAG_OPTIONAL | SP_NTVFLAG_EPHEMERAL))) - { - // The native is either unbound, or it could become unbound in the - // future. Invoke the slower native callback. - __ push(native_index); - __ push(eax); - __ call(ExternalAddress((void *)NativeCallback)); - } else { - // The native is bound so we have a few more guarantees. - __ push(intptr_t(native->pfn)); - __ push(eax); - __ call(ExternalAddress((void *)BoundNativeCallback)); - } - - // Check for errors. - __ movl(ecx, intptr_t(rt_->GetBaseContext()->GetCtx())); - __ movl(ecx, Operand(ecx, offsetof(sp_context_t, n_err))); - __ testl(ecx, ecx); - __ j(not_zero, &extern_error_); - - // Restore local state. - __ addl(stk, dat); - __ addl(esp, 12); - __ pop(edx); - - if (op == OP_SYSREQ_N) { - // Pop the stack. Do not check the margins. - __ addl(stk, (num_params + 1) * sizeof(cell_t)); - } - return true; -} - -bool -Compiler::emitSwitch() -{ - cell_t offset = readCell(); - if (!labelAt(offset)) - return false; - - cell_t *tbl = (cell_t *)((char *)plugin_->pcode + offset + sizeof(cell_t)); - - struct Entry { - cell_t val; - cell_t offset; - }; - - size_t ncases = *tbl++; - - Label *defaultCase = labelAt(*tbl); - if (!defaultCase) - return false; - - // Degenerate - 0 cases. - if (!ncases) { - __ jmp(defaultCase); - return true; - } - - Entry *cases = (Entry *)(tbl + 1); - - // Degenerate - 1 case. - if (ncases == 1) { - Label *maybe = labelAt(cases[0].offset); - if (!maybe) - return false; - __ cmpl(pri, cases[0].val); - __ j(equal, maybe); - __ jmp(defaultCase); - return true; - } - - // We have two or more cases, so let's generate a full switch. Decide - // whether we'll make an if chain, or a jump table, based on whether - // the numbers are strictly sequential. - bool sequential = true; - { - cell_t first = cases[0].val; - cell_t last = first; - for (size_t i = 1; i < ncases; i++) { - if (cases[i].val != ++last) { - sequential = false; - break; - } - } - } - - // First check whether the bounds are correct: if (a < LOW || a > HIGH); - // this check is valid whether or not we emit a sequential-optimized switch. - cell_t low = cases[0].val; - if (low != 0) { - // negate it so we'll get a lower bound of 0. - low = -low; - __ lea(tmp, Operand(pri, low)); - } else { - __ movl(tmp, pri); - } - - cell_t high = abs(cases[0].val - cases[ncases - 1].val); - __ cmpl(tmp, high); - __ j(above, defaultCase); - - if (sequential) { - // Optimized table version. The tomfoolery below is because we only have - // one free register... it seems unlikely pri or alt will be used given - // that we're at the end of a control-flow point, but we'll play it safe. - DataLabel table; - __ push(eax); - __ movl(eax, &table); - __ movl(ecx, Operand(eax, ecx, ScaleFour)); - __ pop(eax); - __ jmp(ecx); - - __ bind(&table); - for (size_t i = 0; i < ncases; i++) { - Label *label = labelAt(cases[i].offset); - if (!label) - return false; - __ emit_absolute_address(label); - } - } else { - // Slower version. Go through each case and generate a check. - for (size_t i = 0; i < ncases; i++) { - Label *label = labelAt(cases[i].offset); - if (!label) - return false; - __ cmpl(pri, cases[i].val); - __ j(equal, label); - } - __ jmp(defaultCase); - } - return true; -} - -void -Compiler::emitErrorPath(Label *dest, int code) -{ - if (dest->used()) { - __ bind(dest); - __ movl(eax, code); - __ jmp(g_Jit.GetUniversalReturn()); - } -} - -void -Compiler::emitFloatCmp(ConditionCode cc) -{ - unsigned lhs = 4; - unsigned rhs = 0; - if (cc == below || cc == below_equal) { - // NaN results in ZF=1 PF=1 CF=1 - // - // ja/jae check for ZF,CF=0 and CF=0. If we make all relational compares - // look like ja/jae, we'll guarantee all NaN comparisons will fail (which - // would not be true for jb/jbe, unless we checked with jp). - if (cc == below) - cc = above; - else - cc = above_equal; - rhs = 4; - lhs = 0; - } - - if (MacroAssemblerX86::Features().sse) { - __ movss(xmm0, Operand(stk, rhs)); - __ ucomiss(Operand(stk, lhs), xmm0); - } else { - __ fld32(Operand(stk, rhs)); - __ fld32(Operand(stk, lhs)); - __ fucomip(st1); - __ fstp(st0); - } - - // An equal or not-equal needs special handling for the parity bit. - if (cc == equal || cc == not_equal) { - // If NaN, PF=1, ZF=1, and E/Z tests ZF=1. - // - // If NaN, PF=1, ZF=1 and NE/NZ tests Z=0. But, we want any != with NaNs - // to return true, including NaN != NaN. - // - // To make checks simpler, we set |eax| to the expected value of a NaN - // beforehand. This also clears the top bits of |eax| for setcc. - Label done; - __ movl(eax, (cc == equal) ? 0 : 1); - __ j(parity, &done); - __ set(cc, r8_al); - __ bind(&done); - } else { - __ movl(eax, 0); - __ set(cc, r8_al); - } - __ addl(stk, 8); -} - -void -Compiler::emitErrorPaths() -{ - emitErrorPath(&error_divide_by_zero_, SP_ERROR_DIVIDE_BY_ZERO); - emitErrorPath(&error_stack_low_, SP_ERROR_STACKLOW); - emitErrorPath(&error_stack_min_, SP_ERROR_STACKMIN); - emitErrorPath(&error_bounds_, SP_ERROR_ARRAY_BOUNDS); - emitErrorPath(&error_memaccess_, SP_ERROR_MEMACCESS); - emitErrorPath(&error_heap_low_, SP_ERROR_HEAPLOW); - emitErrorPath(&error_heap_min_, SP_ERROR_HEAPMIN); - emitErrorPath(&error_integer_overflow_, SP_ERROR_INTEGER_OVERFLOW); - - if (extern_error_.used()) { - __ bind(&extern_error_); - __ movl(eax, intptr_t(rt_->GetBaseContext()->GetCtx())); - __ movl(eax, Operand(eax, offsetof(sp_context_t, n_err))); - __ jmp(g_Jit.GetUniversalReturn()); - } -} - -typedef int (*JIT_EXECUTE)(sp_context_t *ctx, uint8_t *memory, void *code); - -static void * -GenerateEntry(void **retp, void **timeoutp) -{ - AssemblerX86 masm; - - __ push(ebp); - __ movl(ebp, esp); - - __ push(esi); // ebp - 4 - __ push(edi); // ebp - 8 - __ push(ebx); // ebp - 12 - __ push(esp); // ebp - 16 - - __ movl(ebx, Operand(ebp, 8 + 4 * 0)); - __ movl(eax, Operand(ebp, 8 + 4 * 1)); - __ movl(ecx, Operand(ebp, 8 + 4 * 2)); - - // Set up run-time registers. - __ movl(edi, Operand(ebx, offsetof(sp_context_t, sp))); - __ addl(edi, eax); - __ movl(esi, eax); - __ movl(ebx, edi); - - // Align the stack. - __ andl(esp, 0xfffffff0); - - // Call into plugin (align the stack first). - __ call(ecx); - - // Get input context, store rval. - __ movl(ecx, Operand(ebp, 8 + 4 * 0)); - __ movl(Operand(ecx, offsetof(sp_context_t, rval)), pri); - - // Set no error. - __ movl(eax, SP_ERROR_NONE); - - // Store latest stk. If we have an error code, we'll jump directly to here, - // so eax will already be set. - Label ret; - __ bind(&ret); - __ subl(stk, dat); - __ movl(Operand(ecx, offsetof(sp_context_t, sp)), stk); - - // Restore stack. - __ movl(esp, Operand(ebp, -16)); - - // Restore registers and gtfo. - __ pop(ebx); - __ pop(edi); - __ pop(esi); - __ pop(ebp); - __ ret(); - - // The universal emergency return will jump to here. - Label error; - __ bind(&error); - __ movl(ecx, Operand(ebp, 8 + 4 * 0)); // ret-path expects ecx = ctx - __ jmp(&ret); - - Label timeout; - __ bind(&timeout); - __ movl(eax, SP_ERROR_TIMEOUT); - __ jmp(&error); - - void *code = LinkCode(masm); - if (!code) - return NULL; - - *retp = reinterpret_cast(code) + error.offset(); - *timeoutp = reinterpret_cast(code) + timeout.offset(); - return code; -} - -ICompilation *JITX86::ApplyOptions(ICompilation *_IN, ICompilation *_OUT) -{ - if (_IN == NULL) - return _OUT; - - CompData *_in = (CompData * )_IN; - CompData *_out = (CompData * )_OUT; - - _in->inline_level = _out->inline_level; - _in->profile = _out->profile; - - _out->Abort(); - return _in; -} - -JITX86::JITX86() -{ - m_pJitEntry = NULL; -} - -bool -JITX86::InitializeJIT() -{ - g_pCodeCache = KE_CreateCodeCache(); - - m_pJitEntry = GenerateEntry(&m_pJitReturn, &m_pJitTimeout); - if (!m_pJitEntry) - return false; - - MacroAssemblerX86 masm; - MacroAssemblerX86::GenerateFeatureDetection(masm); - void *code = LinkCode(masm); - if (!code) - return false; - MacroAssemblerX86::RunFeatureDetection(code); - KE_FreeCode(g_pCodeCache, code); - - return true; -} - -void -JITX86::ShutdownJIT() -{ - KE_DestroyCodeCache(g_pCodeCache); -} - -JitFunction * -JITX86::CompileFunction(BaseRuntime *prt, cell_t pcode_offs, int *err) -{ - Compiler cc(prt, pcode_offs); - JitFunction *fun = cc.emit(err); - if (!fun) - return NULL; - - // Grab the lock before linking code in, since the watchdog timer will look - // at this list on another thread. - ke::AutoLock lock(g_Jit.Mutex()); - - prt->AddJittedFunction(fun); - return fun; -} - -void -JITX86::SetupContextVars(BaseRuntime *runtime, BaseContext *pCtx, sp_context_t *ctx) -{ - ctx->tracker = new tracker_t; - ctx->tracker->pBase = (ucell_t *)malloc(1024); - ctx->tracker->pCur = ctx->tracker->pBase; - ctx->tracker->size = 1024 / sizeof(cell_t); - ctx->basecx = pCtx; - ctx->plugin = const_cast(runtime->plugin()); -} - -SPVM_NATIVE_FUNC -JITX86::CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData) -{ - AssemblerX86 masm; - - __ push(ebx); - __ push(edi); - __ push(esi); - __ movl(edi, Operand(esp, 16)); // store ctx - __ movl(esi, Operand(esp, 20)); // store params - __ movl(ebx, esp); - __ andl(esp, 0xfffffff0); - __ subl(esp, 4); - - __ push(intptr_t(pData)); - __ push(esi); - __ push(edi); - __ call(ExternalAddress((void *)callback)); - __ movl(esp, ebx); - __ pop(esi); - __ pop(edi); - __ pop(ebx); - __ ret(); - - return (SPVM_NATIVE_FUNC)LinkCode(masm); -} - -void -JITX86::DestroyFakeNative(SPVM_NATIVE_FUNC func) -{ - KE_FreeCode(g_pCodeCache, (void *)func); -} - -ICompilation * -JITX86::StartCompilation() -{ - return new CompData; -} - -ICompilation * -JITX86::StartCompilation(BaseRuntime *runtime) -{ - return new CompData; -} - -void -CompData::Abort() -{ - delete this; -} - -void -JITX86::FreeContextVars(sp_context_t *ctx) -{ - free(ctx->tracker->pBase); - delete ctx->tracker; -} - -bool -CompData::SetOption(const char *key, const char *val) -{ - if (strcmp(key, SP_JITCONF_DEBUG) == 0) - return true; - if (strcmp(key, SP_JITCONF_PROFILE) == 0) { - profile = atoi(val); - - /** Callbacks must be profiled to profile functions! */ - if ((profile & SP_PROF_FUNCTIONS) == SP_PROF_FUNCTIONS) - profile |= SP_PROF_CALLBACKS; - - return true; - } - - return false; -} - -int -JITX86::InvokeFunction(BaseRuntime *runtime, JitFunction *fn, cell_t *result) -{ - sp_context_t *ctx = runtime->GetBaseContext()->GetCtx(); - - // Note that cip, hp, sp are saved and restored by Execute2(). - ctx->cip = fn->GetPCodeAddress(); - - JIT_EXECUTE pfn = (JIT_EXECUTE)m_pJitEntry; - - if (level_++ == 0) - frame_id_++; - int err = pfn(ctx, runtime->plugin()->memory, fn->GetEntryAddress()); - level_--; - - *result = ctx->rval; - return err; -} - -void * -JITX86::AllocCode(size_t size) -{ - return Knight::KE_AllocCode(g_pCodeCache, size); -} - -void -JITX86::FreeCode(void *code) -{ - KE_FreeCode(g_pCodeCache, code); -} - -void -JITX86::RegisterRuntime(BaseRuntime *rt) -{ - mutex_.AssertCurrentThreadOwns(); - runtimes_.append(rt); -} - -void -JITX86::DeregisterRuntime(BaseRuntime *rt) -{ - mutex_.AssertCurrentThreadOwns(); - runtimes_.remove(rt); -} - -void -JITX86::PatchAllJumpsForTimeout() -{ - mutex_.AssertCurrentThreadOwns(); - for (ke::InlineList::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) { - BaseRuntime *rt = *iter; - for (size_t i = 0; i < rt->NumJitFunctions(); i++) { - JitFunction *fun = rt->GetJitFunction(i); - uint8_t *base = reinterpret_cast(fun->GetEntryAddress()); - - for (size_t j = 0; j < fun->NumLoopEdges(); j++) { - const LoopEdge &e = fun->GetLoopEdge(j); - int32_t diff = intptr_t(m_pJitTimeout) - intptr_t(base + e.offset); - *reinterpret_cast(base + e.offset - 4) = diff; - } - } - } -} - -void -JITX86::UnpatchAllJumpsFromTimeout() -{ - mutex_.AssertCurrentThreadOwns(); - for (ke::InlineList::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) { - BaseRuntime *rt = *iter; - for (size_t i = 0; i < rt->NumJitFunctions(); i++) { - JitFunction *fun = rt->GetJitFunction(i); - uint8_t *base = reinterpret_cast(fun->GetEntryAddress()); - - for (size_t j = 0; j < fun->NumLoopEdges(); j++) { - const LoopEdge &e = fun->GetLoopEdge(j); - *reinterpret_cast(base + e.offset - 4) = e.disp32; - } - } - } -} diff --git a/sourcepawn/jit/x86/jit_x86.h b/sourcepawn/jit/x86/jit_x86.h deleted file mode 100644 index daaec0f2..00000000 --- a/sourcepawn/jit/x86/jit_x86.h +++ /dev/null @@ -1,210 +0,0 @@ -// vim: set ts=8 sts=2 sw=2 tw=99 et: -// -// This file is part of SourcePawn. -// -// SourcePawn is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// SourcePawn 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 SourcePawn. If not, see . -#ifndef _INCLUDE_SOURCEPAWN_JIT_X86_H_ -#define _INCLUDE_SOURCEPAWN_JIT_X86_H_ - -#include -#include -#include -#include -#include -#include "jit_shared.h" -#include "BaseRuntime.h" -#include "sp_vm_basecontext.h" -#include "jit_function.h" -#include "opcodes.h" -#include - -using namespace SourcePawn; - -#define JIT_INLINE_ERRORCHECKS (1<<0) -#define JIT_INLINE_NATIVES (1<<1) -#define STACK_MARGIN 64 //8 parameters of safety, I guess -#define JIT_FUNCMAGIC 0x214D4148 //magic function offset - -#define JITVARS_PROFILER 2 //profiler - -#define sDIMEN_MAX 5 //this must mirror what the compiler has. - -typedef struct funcinfo_s -{ - unsigned int magic; - unsigned int index; -} funcinfo_t; - -typedef struct functracker_s -{ - unsigned int num_functions; - unsigned int code_size; -} functracker_t; - -struct CallThunk -{ - Label call; - cell_t pcode_offset; - - CallThunk(cell_t pcode_offset) - : pcode_offset(pcode_offset) - { - } -}; - -class CompData : public ICompilation -{ -public: - CompData() - : profile(0), - inline_level(0) - { - }; - bool SetOption(const char *key, const char *val); - void Abort(); -public: - cell_t cur_func; /* current func pcode offset */ - /* Options */ - int profile; /* profiling flags */ - int inline_level; /* inline optimization level */ - /* Per-compilation properties */ - unsigned int func_idx; /* current function index */ -}; - -class Compiler -{ - public: - Compiler(BaseRuntime *rt, cell_t pcode_offs); - ~Compiler(); - - JitFunction *emit(int *errp); - - private: - bool setup(cell_t pcode_offs); - bool emitOp(OPCODE op); - cell_t readCell(); - - private: - Label *labelAt(size_t offset); - bool emitCall(); - bool emitNativeCall(OPCODE op); - bool emitSwitch(); - void emitGenArray(bool autozero); - void emitCallThunks(); - void emitCheckAddress(Register reg); - void emitErrorPath(Label *dest, int code); - void emitErrorPaths(); - void emitFloatCmp(ConditionCode cc); - - ExternalAddress cipAddr() { - sp_context_t *ctx = rt_->GetBaseContext()->GetCtx(); - return ExternalAddress(&ctx->cip); - } - ExternalAddress hpAddr() { - sp_context_t *ctx = rt_->GetBaseContext()->GetCtx(); - return ExternalAddress(&ctx->hp); - } - ExternalAddress frmAddr() { - sp_context_t *ctx = rt_->GetBaseContext()->GetCtx(); - return ExternalAddress(&ctx->frm); - } - - private: - AssemblerX86 masm; - BaseRuntime *rt_; - const sp_plugin_t *plugin_; - int error_; - uint32_t pcode_start_; - cell_t *code_start_; - cell_t *cip_; - cell_t *code_end_; - Label *jump_map_; - ke::Vector backward_jumps_; - - // Errors - Label error_bounds_; - Label error_heap_low_; - Label error_heap_min_; - Label error_stack_low_; - Label error_stack_min_; - Label error_divide_by_zero_; - Label error_memaccess_; - Label error_integer_overflow_; - Label extern_error_; - - ke::Vector thunks_; //:TODO: free -}; - -class JITX86 -{ - public: - JITX86(); - - public: - bool InitializeJIT(); - void ShutdownJIT(); - ICompilation *StartCompilation(BaseRuntime *runtime); - ICompilation *StartCompilation(); - void SetupContextVars(BaseRuntime *runtime, BaseContext *pCtx, sp_context_t *ctx); - void FreeContextVars(sp_context_t *ctx); - SPVM_NATIVE_FUNC CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData); - void DestroyFakeNative(SPVM_NATIVE_FUNC func); - JitFunction *CompileFunction(BaseRuntime *runtime, cell_t pcode_offs, int *err); - ICompilation *ApplyOptions(ICompilation *_IN, ICompilation *_OUT); - int InvokeFunction(BaseRuntime *runtime, JitFunction *fn, cell_t *result); - - void RegisterRuntime(BaseRuntime *rt); - void DeregisterRuntime(BaseRuntime *rt); - void PatchAllJumpsForTimeout(); - void UnpatchAllJumpsFromTimeout(); - - public: - ExternalAddress GetUniversalReturn() { - return ExternalAddress(m_pJitReturn); - } - void *AllocCode(size_t size); - void FreeCode(void *code); - - uintptr_t FrameId() const { - return frame_id_; - } - bool RunningCode() const { - return level_ != 0; - } - ke::Mutex *Mutex() { - return &mutex_; - } - - private: - void *m_pJitEntry; /* Entry function */ - void *m_pJitReturn; /* Universal return address */ - void *m_pJitTimeout; /* Universal timeout address */ - ke::InlineList runtimes_; - uintptr_t frame_id_; - uintptr_t level_; - ke::Mutex mutex_; -}; - -const Register pri = eax; -const Register alt = edx; -const Register stk = edi; -const Register dat = esi; -const Register tmp = ecx; -const Register frm = ebx; - -extern Knight::KeCodeCache *g_pCodeCache; -extern JITX86 g_Jit; - -#endif //_INCLUDE_SOURCEPAWN_JIT_X86_H_ - diff --git a/sourcepawn/jit/zlib/adler32.c b/sourcepawn/jit/zlib/adler32.c deleted file mode 100644 index f201d670..00000000 --- a/sourcepawn/jit/zlib/adler32.c +++ /dev/null @@ -1,149 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -#define BASE 65521UL /* largest prime smaller than 65536 */ -#define NMAX 5552 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - -#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} -#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); -#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); -#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); -#define DO16(buf) DO8(buf,0); DO8(buf,8); - -/* use NO_DIVIDE if your processor does not do division in hardware */ -#ifdef NO_DIVIDE -# define MOD(a) \ - do { \ - if (a >= (BASE << 16)) a -= (BASE << 16); \ - if (a >= (BASE << 15)) a -= (BASE << 15); \ - if (a >= (BASE << 14)) a -= (BASE << 14); \ - if (a >= (BASE << 13)) a -= (BASE << 13); \ - if (a >= (BASE << 12)) a -= (BASE << 12); \ - if (a >= (BASE << 11)) a -= (BASE << 11); \ - if (a >= (BASE << 10)) a -= (BASE << 10); \ - if (a >= (BASE << 9)) a -= (BASE << 9); \ - if (a >= (BASE << 8)) a -= (BASE << 8); \ - if (a >= (BASE << 7)) a -= (BASE << 7); \ - if (a >= (BASE << 6)) a -= (BASE << 6); \ - if (a >= (BASE << 5)) a -= (BASE << 5); \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ - if (a >= BASE) a -= BASE; \ - } while (0) -# define MOD4(a) \ - do { \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ - if (a >= BASE) a -= BASE; \ - } while (0) -#else -# define MOD(a) a %= BASE -# define MOD4(a) a %= BASE -#endif - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - unsigned long sum2; - unsigned n; - - /* split Adler-32 into component sums */ - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (len == 1) { - adler += buf[0]; - if (adler >= BASE) - adler -= BASE; - sum2 += adler; - if (sum2 >= BASE) - sum2 -= BASE; - return adler | (sum2 << 16); - } - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (buf == Z_NULL) - return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (len < 16) { - while (len--) { - adler += *buf++; - sum2 += adler; - } - if (adler >= BASE) - adler -= BASE; - MOD4(sum2); /* only added so many BASE's */ - return adler | (sum2 << 16); - } - - /* do length NMAX blocks -- requires just one modulo operation */ - while (len >= NMAX) { - len -= NMAX; - n = NMAX / 16; /* NMAX is divisible by 16 */ - do { - DO16(buf); /* 16 sums unrolled */ - buf += 16; - } while (--n); - MOD(adler); - MOD(sum2); - } - - /* do remaining bytes (less than NMAX, still just one modulo) */ - if (len) { /* avoid modulos if none remaining */ - while (len >= 16) { - len -= 16; - DO16(buf); - buf += 16; - } - while (len--) { - adler += *buf++; - sum2 += adler; - } - MOD(adler); - MOD(sum2); - } - - /* return recombined sums */ - return adler | (sum2 << 16); -} - -/* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ - unsigned long sum1; - unsigned long sum2; - unsigned rem; - - /* the derivation of this formula is left as an exercise for the reader */ - rem = (unsigned)(len2 % BASE); - sum1 = adler1 & 0xffff; - sum2 = rem * sum1; - MOD(sum2); - sum1 += (adler2 & 0xffff) + BASE - 1; - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; - if (sum1 > BASE) sum1 -= BASE; - if (sum1 > BASE) sum1 -= BASE; - if (sum2 > (BASE << 1)) sum2 -= (BASE << 1); - if (sum2 > BASE) sum2 -= BASE; - return sum1 | (sum2 << 16); -} diff --git a/sourcepawn/jit/zlib/compress.c b/sourcepawn/jit/zlib/compress.c deleted file mode 100644 index d37e84f5..00000000 --- a/sourcepawn/jit/zlib/compress.c +++ /dev/null @@ -1,79 +0,0 @@ -/* compress.c -- compress a memory buffer - * Copyright (C) 1995-2003 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least 0.1% larger than sourceLen plus - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ - z_stream stream; - int err; - - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; -#ifdef MAXSEG_64K - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; -#endif - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - - err = deflateInit(&stream, level); - if (err != Z_OK) return err; - - err = deflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - deflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = deflateEnd(&stream); - return err; -} - -/* =========================================================================== - */ -int ZEXPORT compress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); -} - -/* =========================================================================== - If the default memLevel or windowBits for deflateInit() is changed, then - this function needs to be updated. - */ -uLong ZEXPORT compressBound (sourceLen) - uLong sourceLen; -{ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; -} diff --git a/sourcepawn/jit/zlib/crc32.c b/sourcepawn/jit/zlib/crc32.c deleted file mode 100644 index 5e8c44be..00000000 --- a/sourcepawn/jit/zlib/crc32.c +++ /dev/null @@ -1,424 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Thanks to Rodney Brown for his contribution of faster - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing - * tables for updating the shift register in one step with three exclusive-ors - * instead of four steps with four exclusive-ors. This results in about a - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. - */ - -/* @(#) $Id$ */ - -/* - Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore - protection on the static variables used to control the first-use generation - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should - first call get_crc_table() to initialize the tables before allowing more than - one thread to use crc32(). - */ - -#include -#ifdef MAKECRCH -# include -# ifndef DYNAMIC_CRC_TABLE -# define DYNAMIC_CRC_TABLE -# endif /* !DYNAMIC_CRC_TABLE */ -#endif /* MAKECRCH */ - -#include "zutil.h" /* for STDC and FAR definitions */ - -#define local static - -/* Find a four-byte integer type for crc32_little() and crc32_big(). */ -#ifndef NOBYFOUR -# ifdef STDC /* need ANSI C limits.h to determine sizes */ -# include -# define BYFOUR -# if (UINT_MAX == 0xffffffffUL) - typedef unsigned int u4; -# else -# if (ULONG_MAX == 0xffffffffUL) - typedef unsigned long u4; -# else -# if (USHRT_MAX == 0xffffffffUL) - typedef unsigned short u4; -# else -# undef BYFOUR /* can't find a four-byte integer type! */ -# endif -# endif -# endif -# endif /* STDC */ -#endif /* !NOBYFOUR */ - -/* Definitions for doing the crc four data bytes at a time. */ -#ifdef BYFOUR -# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ - (((w)&0xff00)<<8)+(((w)&0xff)<<24)) - local unsigned long crc32_little OF((unsigned long, - const unsigned char FAR *, unsigned)); - local unsigned long crc32_big OF((unsigned long, - const unsigned char FAR *, unsigned)); -# define TBLS 8 -#else -# define TBLS 1 -#endif /* BYFOUR */ - -/* Local functions for crc concatenation */ -local unsigned long gf2_matrix_times OF((unsigned long *mat, - unsigned long vec)); -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); - -#ifdef DYNAMIC_CRC_TABLE - -local volatile int crc_table_empty = 1; -local unsigned long FAR crc_table[TBLS][256]; -local void make_crc_table OF((void)); -#ifdef MAKECRCH - local void write_table OF((FILE *, const unsigned long FAR *)); -#endif /* MAKECRCH */ -/* - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The first table is simply the CRC of all possible eight bit values. This is - all the information needed to generate CRCs on data a byte at a time for all - combinations of CRC register values and incoming bytes. The remaining tables - allow for word-at-a-time CRC calculation for both big-endian and little- - endian machines, where a word is four bytes. -*/ -local void make_crc_table() -{ - unsigned long c; - int n, k; - unsigned long poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static volatile int first = 1; /* flag to limit concurrent making */ - static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* See if another task is already doing this (not thread-safe, but better - than nothing -- significantly reduces duration of vulnerability in - case the advice about DYNAMIC_CRC_TABLE is ignored) */ - if (first) { - first = 0; - - /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0UL; - for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) - poly |= 1UL << (31 - p[n]); - - /* generate a crc for every 8-bit value */ - for (n = 0; n < 256; n++) { - c = (unsigned long)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[0][n] = c; - } - -#ifdef BYFOUR - /* generate crc for each value followed by one, two, and three zeros, - and then the byte reversal of those as well as the first table */ - for (n = 0; n < 256; n++) { - c = crc_table[0][n]; - crc_table[4][n] = REV(c); - for (k = 1; k < 4; k++) { - c = crc_table[0][c & 0xff] ^ (c >> 8); - crc_table[k][n] = c; - crc_table[k + 4][n] = REV(c); - } - } -#endif /* BYFOUR */ - - crc_table_empty = 0; - } - else { /* not first */ - /* wait for the other guy to finish (not efficient, but rare) */ - while (crc_table_empty) - ; - } - -#ifdef MAKECRCH - /* write out CRC tables to crc32.h */ - { - FILE *out; - - out = fopen("crc32.h", "w"); - if (out == NULL) return; - fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); - fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const unsigned long FAR "); - fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); - write_table(out, crc_table[0]); -# ifdef BYFOUR - fprintf(out, "#ifdef BYFOUR\n"); - for (k = 1; k < 8; k++) { - fprintf(out, " },\n {\n"); - write_table(out, crc_table[k]); - } - fprintf(out, "#endif\n"); -# endif /* BYFOUR */ - fprintf(out, " }\n};\n"); - fclose(out); - } -#endif /* MAKECRCH */ -} - -#ifdef MAKECRCH -local void write_table(out, table) - FILE *out; - const unsigned long FAR *table; -{ - int n; - - for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], - n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); -} -#endif /* MAKECRCH */ - -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables of CRC-32s of all single-byte values, made by make_crc_table(). - */ -#include "crc32.h" -#endif /* DYNAMIC_CRC_TABLE */ - -/* ========================================================================= - * This function can be used by asm versions of crc32() - */ -const unsigned long FAR * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - return (const unsigned long FAR *)crc_table; -} - -/* ========================================================================= */ -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 - -/* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - if (buf == Z_NULL) return 0UL; - -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - -#ifdef BYFOUR - if (sizeof(void *) == sizeof(ptrdiff_t)) { - u4 endian; - - endian = 1; - if (*((unsigned char *)(&endian))) - return crc32_little(crc, buf, len); - else - return crc32_big(crc, buf, len); - } -#endif /* BYFOUR */ - crc = crc ^ 0xffffffffUL; - while (len >= 8) { - DO8; - len -= 8; - } - if (len) do { - DO1; - } while (--len); - return crc ^ 0xffffffffUL; -} - -#ifdef BYFOUR - -/* ========================================================================= */ -#define DOLIT4 c ^= *buf4++; \ - c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ - crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 - -/* ========================================================================= */ -local unsigned long crc32_little(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register u4 c; - register const u4 FAR *buf4; - - c = (u4)crc; - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - len--; - } - - buf4 = (const u4 FAR *)(const void FAR *)buf; - while (len >= 32) { - DOLIT32; - len -= 32; - } - while (len >= 4) { - DOLIT4; - len -= 4; - } - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - } while (--len); - c = ~c; - return (unsigned long)c; -} - -/* ========================================================================= */ -#define DOBIG4 c ^= *++buf4; \ - c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ - crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 - -/* ========================================================================= */ -local unsigned long crc32_big(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register u4 c; - register const u4 FAR *buf4; - - c = REV((u4)crc); - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - len--; - } - - buf4 = (const u4 FAR *)(const void FAR *)buf; - buf4--; - while (len >= 32) { - DOBIG32; - len -= 32; - } - while (len >= 4) { - DOBIG4; - len -= 4; - } - buf4++; - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - } while (--len); - c = ~c; - return (unsigned long)(REV(c)); -} - -#endif /* BYFOUR */ - -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ - -/* ========================================================================= */ -local unsigned long gf2_matrix_times(mat, vec) - unsigned long *mat; - unsigned long vec; -{ - unsigned long sum; - - sum = 0; - while (vec) { - if (vec & 1) - sum ^= *mat; - vec >>= 1; - mat++; - } - return sum; -} - -/* ========================================================================= */ -local void gf2_matrix_square(square, mat) - unsigned long *square; - unsigned long *mat; -{ - int n; - - for (n = 0; n < GF2_DIM; n++) - square[n] = gf2_matrix_times(mat, mat[n]); -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ - int n; - unsigned long row; - unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ - unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ - - /* degenerate case */ - if (len2 == 0) - return crc1; - - /* put operator for one zero bit in odd */ - odd[0] = 0xedb88320L; /* CRC-32 polynomial */ - row = 1; - for (n = 1; n < GF2_DIM; n++) { - odd[n] = row; - row <<= 1; - } - - /* put operator for two zero bits in even */ - gf2_matrix_square(even, odd); - - /* put operator for four zero bits in odd */ - gf2_matrix_square(odd, even); - - /* apply len2 zeros to crc1 (first square will put the operator for one - zero byte, eight zero bits, in even) */ - do { - /* apply zeros operator for this bit of len2 */ - gf2_matrix_square(even, odd); - if (len2 & 1) - crc1 = gf2_matrix_times(even, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - if (len2 == 0) - break; - - /* another iteration of the loop with odd and even swapped */ - gf2_matrix_square(odd, even); - if (len2 & 1) - crc1 = gf2_matrix_times(odd, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - } while (len2 != 0); - - /* return combined crc */ - crc1 ^= crc2; - return crc1; -} diff --git a/sourcepawn/jit/zlib/crc32.h b/sourcepawn/jit/zlib/crc32.h deleted file mode 100644 index 5de49bc9..00000000 --- a/sourcepawn/jit/zlib/crc32.h +++ /dev/null @@ -1,441 +0,0 @@ -/* crc32.h -- tables for rapid CRC calculation - * Generated automatically by crc32.c - */ - -local const unsigned long FAR crc_table[TBLS][256] = -{ - { - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, - 0x2d02ef8dUL -#ifdef BYFOUR - }, - { - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, - 0x9324fd72UL - }, - { - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, - 0xbe9834edUL - }, - { - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, - 0xde0506f1UL - }, - { - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, - 0x8def022dUL - }, - { - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, - 0x72fd2493UL - }, - { - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, - 0xed3498beUL - }, - { - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, - 0xf10605deUL -#endif - } -}; diff --git a/sourcepawn/jit/zlib/deflate.c b/sourcepawn/jit/zlib/deflate.c deleted file mode 100644 index f58dee25..00000000 --- a/sourcepawn/jit/zlib/deflate.c +++ /dev/null @@ -1,1737 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many people for bug reports and testing. - * - * REFERENCES - * - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in http://www.ietf.org/rfc/rfc1951.txt - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - */ - -/* @(#) $Id$ */ - -#include -#include "deflate.h" - -const char deflate_copyright[] = - " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* =========================================================================== - * Function prototypes. - */ -typedef enum { - need_more, /* block not completed, need more input or more output */ - block_done, /* block flush performed */ - finish_started, /* finish started, need only more output at next deflate */ - finish_done /* finish done, accept no more input or output */ -} block_state; - -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); -/* Compression function. Returns the block state after the call. */ - -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); -#ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -#ifndef FASTEST -#ifdef ASMV - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); -#else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); -#endif -#endif -local uInt longest_match_fast OF((deflate_state *s, IPos cur_match)); - -#ifdef DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); -#endif - -/* =========================================================================== - * Local data - */ - -#define NIL 0 -/* Tail of hash chains */ - -#ifndef TOO_FAR -# define TOO_FAR 4096 -#endif -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ -typedef struct config_s { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; - compress_func func; -} config; - -#ifdef FASTEST -local const config configuration_table[2] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ -#else -local const config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ -/* 2 */ {4, 5, 16, 8, deflate_fast}, -/* 3 */ {4, 6, 32, 32, deflate_fast}, - -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ -/* 5 */ {8, 16, 32, 32, deflate_slow}, -/* 6 */ {8, 16, 128, 128, deflate_slow}, -/* 7 */ {8, 32, 128, 256, deflate_slow}, -/* 8 */ {32, 128, 258, 1024, deflate_slow}, -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ -#endif - -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different - * meaning. - */ - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -#ifndef NO_DUMMY_DECL -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ -#endif - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. - */ -#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) - - -/* =========================================================================== - * Insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - * If this file is compiled with -DFASTEST, the compression level is forced - * to 1, and no hash chains are maintained. - * IN assertion: all calls to to INSERT_STRING are made with consecutive - * input characters and the first MIN_MATCH bytes of str are valid - * (except for the last MIN_MATCH-1 bytes of the input file). - */ -#ifdef FASTEST -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#else -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#endif - -/* =========================================================================== - * Initialize the hash table (avoiding 64K overflow for 16 bit systems). - * prev[] will be initialized on the fly. - */ -#define CLEAR_HASH(s) \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); - -/* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); - /* To do: ignore strm->next_in if we use it as window */ -} - -/* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ - deflate_state *s; - int wrap = 1; - static const char my_version[] = ZLIB_VERSION; - - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - - if (version == Z_NULL || version[0] != my_version[0] || - stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; - } - if (strm == Z_NULL) return Z_STREAM_ERROR; - - strm->msg = Z_NULL; - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - - if (windowBits < 0) { /* suppress zlib wrapper */ - wrap = 0; - windowBits = -windowBits; - } -#ifdef GZIP - else if (windowBits > 15) { - wrap = 2; /* write gzip wrapper instead */ - windowBits -= 16; - } -#endif - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - - s->wrap = wrap; - s->gzhead = Z_NULL; - s->w_bits = windowBits; - s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; - - s->hash_bits = memLevel + 7; - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); - - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); - - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); - - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || - s->pending_buf == Z_NULL) { - s->status = FINISH_STATE; - strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); - deflateEnd (strm); - return Z_MEM_ERROR; - } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; - - s->level = level; - s->strategy = strategy; - s->method = (Byte)method; - - return deflateReset(strm); -} - -/* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ - deflate_state *s; - uInt length = dictLength; - uInt n; - IPos hash_head = 0; - - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || - strm->state->wrap == 2 || - (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) - return Z_STREAM_ERROR; - - s = strm->state; - if (s->wrap) - strm->adler = adler32(strm->adler, dictionary, dictLength); - - if (length < MIN_MATCH) return Z_OK; - if (length > MAX_DIST(s)) { - length = MAX_DIST(s); - dictionary += dictLength - length; /* use the tail of the dictionary */ - } - zmemcpy(s->window, dictionary, length); - s->strstart = length; - s->block_start = (long)length; - - /* Insert all strings in the hash table (except for the last two bytes). - * s->lookahead stays null, so s->ins_h will be recomputed at the next - * call of fill_window. - */ - s->ins_h = s->window[0]; - UPDATE_HASH(s, s->ins_h, s->window[1]); - for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); - } - if (hash_head) hash_head = 0; /* to make compiler happy */ - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { - return Z_STREAM_ERROR; - } - - strm->total_in = strm->total_out = 0; - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ - strm->data_type = Z_UNKNOWN; - - s = (deflate_state *)strm->state; - s->pending = 0; - s->pending_out = s->pending_buf; - - if (s->wrap < 0) { - s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ - } - s->status = s->wrap ? INIT_STATE : BUSY_STATE; - strm->adler = -#ifdef GZIP - s->wrap == 2 ? crc32(0L, Z_NULL, 0) : -#endif - adler32(0L, Z_NULL, 0); - s->last_flush = Z_NO_FLUSH; - - _tr_init(s); - lm_init(s); - - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateSetHeader (strm, head) - z_streamp strm; - gz_headerp head; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - if (strm->state->wrap != 2) return Z_STREAM_ERROR; - strm->state->gzhead = head; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflatePrime (strm, bits, value) - z_streamp strm; - int bits; - int value; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - strm->state->bi_valid = bits; - strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ - deflate_state *s; - compress_func func; - int err = Z_OK; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if (func != configuration_table[level].func && strm->total_in != 0) { - /* Flush the last buffer: */ - err = deflate(strm, Z_PARTIAL_FLUSH); - } - if (s->level != level) { - s->level = level; - s->max_lazy_match = configuration_table[level].max_lazy; - s->good_match = configuration_table[level].good_length; - s->nice_match = configuration_table[level].nice_length; - s->max_chain_length = configuration_table[level].max_chain; - } - s->strategy = strategy; - return err; -} - -/* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - s->good_match = good_length; - s->max_lazy_match = max_lazy; - s->nice_match = nice_length; - s->max_chain_length = max_chain; - return Z_OK; -} - -/* ========================================================================= - * For the default windowBits of 15 and memLevel of 8, this function returns - * a close to exact, as well as small, upper bound on the compressed size. - * They are coded as constants here for a reason--if the #define's are - * changed, then this function needs to be changed as well. The return - * value for 15 and 8 only works for those exact settings. - * - * For any setting other than those defaults for windowBits and memLevel, - * the value returned is a conservative worst case for the maximum expansion - * resulting from using fixed blocks instead of stored blocks, which deflate - * can emit on compressed data for some combinations of the parameters. - * - * This function could be more sophisticated to provide closer upper bounds - * for every combination of windowBits and memLevel, as well as wrap. - * But even the conservative upper bound of about 14% expansion does not - * seem onerous for output buffer allocation. - */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ - deflate_state *s; - uLong destLen; - - /* conservative upper bound */ - destLen = sourceLen + - ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11; - - /* if can't get parameters, return conservative bound */ - if (strm == Z_NULL || strm->state == Z_NULL) - return destLen; - - /* if not default parameters, return conservative bound */ - s = strm->state; - if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return destLen; - - /* default settings: return tight bound for that case */ - return compressBound(sourceLen); -} - -/* ========================================================================= - * Put a short in the pending buffer. The 16-bit value is put in MSB order. - * IN assertion: the stream state is correct and there is enough room in - * pending_buf. - */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; -{ - put_byte(s, (Byte)(b >> 8)); - put_byte(s, (Byte)(b & 0xff)); -} - -/* ========================================================================= - * Flush as much pending output as possible. All deflate() output goes - * through this function so some applications may wish to modify it - * to avoid allocating a large strm->next_out buffer and copying into it. - * (See also read_buf()). - */ -local void flush_pending(strm) - z_streamp strm; -{ - unsigned len = strm->state->pending; - - if (len > strm->avail_out) len = strm->avail_out; - if (len == 0) return; - - zmemcpy(strm->next_out, strm->state->pending_out, len); - strm->next_out += len; - strm->state->pending_out += len; - strm->total_out += len; - strm->avail_out -= len; - strm->state->pending -= len; - if (strm->state->pending == 0) { - strm->state->pending_out = strm->state->pending_buf; - } -} - -/* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; -{ - int old_flush; /* value of flush param for previous deflate call */ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_FINISH || flush < 0) { - return Z_STREAM_ERROR; - } - s = strm->state; - - if (strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { - ERR_RETURN(strm, Z_STREAM_ERROR); - } - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - - s->strm = strm; /* just in case */ - old_flush = s->last_flush; - s->last_flush = flush; - - /* Write the header */ - if (s->status == INIT_STATE) { -#ifdef GZIP - if (s->wrap == 2) { - strm->adler = crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (s->gzhead == NULL) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s->status = BUSY_STATE; - } - else { - put_byte(s, (s->gzhead->text ? 1 : 0) + - (s->gzhead->hcrc ? 2 : 0) + - (s->gzhead->extra == Z_NULL ? 0 : 4) + - (s->gzhead->name == Z_NULL ? 0 : 8) + - (s->gzhead->comment == Z_NULL ? 0 : 16) - ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != NULL) { - put_byte(s, s->gzhead->extra_len & 0xff); - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); - } - if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, - s->pending); - s->gzindex = 0; - s->status = EXTRA_STATE; - } - } - else -#endif - { - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags; - - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) - level_flags = 0; - else if (s->level < 6) - level_flags = 1; - else if (s->level == 6) - level_flags = 2; - else - level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - s->status = BUSY_STATE; - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = adler32(0L, Z_NULL, 0); - } - } -#ifdef GZIP - if (s->status == EXTRA_STATE) { - if (s->gzhead->extra != NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - - while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) - break; - } - put_byte(s, s->gzhead->extra[s->gzindex]); - s->gzindex++; - } - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (s->gzindex == s->gzhead->extra_len) { - s->gzindex = 0; - s->status = NAME_STATE; - } - } - else - s->status = NAME_STATE; - } - if (s->status == NAME_STATE) { - if (s->gzhead->name != NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->name[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) { - s->gzindex = 0; - s->status = COMMENT_STATE; - } - } - else - s->status = COMMENT_STATE; - } - if (s->status == COMMENT_STATE) { - if (s->gzhead->comment != NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->comment[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) - s->status = HCRC_STATE; - } - else - s->status = HCRC_STATE; - } - if (s->status == HCRC_STATE) { - if (s->gzhead->hcrc) { - if (s->pending + 2 > s->pending_buf_size) - flush_pending(strm); - if (s->pending + 2 <= s->pending_buf_size) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - strm->adler = crc32(0L, Z_NULL, 0); - s->status = BUSY_STATE; - } - } - else - s->status = BUSY_STATE; - } -#endif - - /* Flush as much pending output as possible */ - if (s->pending != 0) { - flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s->last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm->avail_in == 0 && flush <= old_flush && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* Start a new block or continue the current one. - */ - if (strm->avail_in != 0 || s->lookahead != 0 || - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { - block_state bstate; - - bstate = (*(configuration_table[s->level].func))(s, flush); - - if (bstate == finish_started || bstate == finish_done) { - s->status = FINISH_STATE; - } - if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate == block_done) { - if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); - } else { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush == Z_FULL_FLUSH) { - CLEAR_HASH(s); /* forget history */ - } - } - flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - Assert(strm->avail_out > 0, "bug2"); - - if (flush != Z_FINISH) return Z_OK; - if (s->wrap <= 0) return Z_STREAM_END; - - /* Write the trailer */ -#ifdef GZIP - if (s->wrap == 2) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); - put_byte(s, (Byte)(strm->total_in & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); - } - else -#endif - { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; -} - -/* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; -{ - int status; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - - status = strm->state->status; - if (status != INIT_STATE && - status != EXTRA_STATE && - status != NAME_STATE && - status != COMMENT_STATE && - status != HCRC_STATE && - status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, strm->state->pending_buf); - TRY_FREE(strm, strm->state->head); - TRY_FREE(strm, strm->state->prev); - TRY_FREE(strm, strm->state->window); - - ZFREE(strm, strm->state); - strm->state = Z_NULL; - - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; -} - -/* ========================================================================= - * Copy the source state to the destination state. - * To simplify the source, this is not supported for 16-bit MSDOS (which - * doesn't have enough memory anyway to duplicate compression states). - */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; -{ -#ifdef MAXSEG_64K - return Z_STREAM_ERROR; -#else - deflate_state *ds; - deflate_state *ss; - ushf *overlay; - - - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { - return Z_STREAM_ERROR; - } - - ss = source->state; - - zmemcpy(dest, source, sizeof(z_stream)); - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - zmemcpy(ds, ss, sizeof(deflate_state)); - ds->strm = dest; - - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); - ds->pending_buf = (uchf *) overlay; - - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || - ds->pending_buf == Z_NULL) { - deflateEnd (dest); - return Z_MEM_ERROR; - } - /* following zmemcpy do not work for 16-bit MSDOS */ - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); - - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; - - ds->l_desc.dyn_tree = ds->dyn_ltree; - ds->d_desc.dyn_tree = ds->dyn_dtree; - ds->bl_desc.dyn_tree = ds->bl_tree; - - return Z_OK; -#endif /* MAXSEG_64K */ -} - -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local int read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, strm->next_in, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, strm->next_in, len); - } -#endif - zmemcpy(buf, strm->next_in, len); - strm->next_in += len; - strm->total_in += len; - - return (int)len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init (s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifndef FASTEST -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -#endif -} - -#ifndef FASTEST -/* =========================================================================== - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - * OUT assertion: the match length is not greater than s->lookahead. - */ -#ifndef ASMV -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or - * match.S. The code will be functionally equivalent. - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - unsigned chain_length = s->max_chain_length;/* max hash chain length */ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - int best_len = s->prev_length; /* best match length so far */ - int nice_match = s->nice_match; /* stop if match long enough */ - IPos limit = s->strstart > (IPos)MAX_DIST(s) ? - s->strstart - (IPos)MAX_DIST(s) : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - Posf *prev = s->prev; - uInt wmask = s->w_mask; - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; - register ush scan_start = *(ushf*)scan; - register ush scan_end = *(ushf*)(scan+best_len-1); -#else - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - register Byte scan_end1 = scan[best_len-1]; - register Byte scan_end = scan[best_len]; -#endif - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - /* Do not waste too much time if we already have a good match: */ - if (s->prev_length >= s->good_match) { - chain_length >>= 2; - } - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - do { - Assert(cur_match < s->strstart, "no future"); - match = s->window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2. Note that the checks below - * for insufficient lookahead only occur occasionally for performance - * reasons. Therefore uninitialized memory will be accessed, and - * conditional jumps will be made that depend on those values. - * However the length of the match is limited to the lookahead, so - * the output of deflate is not affected by the uninitialized values. - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ushf*)(match+best_len-1) != scan_end || - *(ushf*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - Assert(scan[2] == match[2], "scan[2]?"); - scan++, match++; - do { - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - s->match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ushf*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & wmask]) > limit - && --chain_length != 0); - - if ((uInt)best_len <= s->lookahead) return (uInt)best_len; - return s->lookahead; -} -#endif /* ASMV */ -#endif /* FASTEST */ - -/* --------------------------------------------------------------------------- - * Optimized version for level == 1 or strategy == Z_RLE only - */ -local uInt longest_match_fast(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - Assert(cur_match < s->strstart, "no future"); - - match = s->window + cur_match; - - /* Return failure if the match length is less than 2: - */ - if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match += 2; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - - if (len < MIN_MATCH) return MIN_MATCH - 1; - - s->match_start = cur_match; - return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; -} - -#ifdef DEBUG -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); - do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); - z_error("invalid match"); - } - if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(s, start, match, length) -#endif /* DEBUG */ - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - register unsigned n, m; - register Posf *p; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize+MAX_DIST(s)) { - - zmemcpy(s->window, s->window+wsize, (unsigned)wsize); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - - /* Slide the hash table (could be avoided with 32 bit values - at the expense of memory usage). We slide even when level == 0 - to keep the hash table consistent if we switch back to level > 0 - later. (Using level 0 permanently is not an optimal usage of - zlib, so we don't care about this pathological case.) - */ - /* %%% avoid this when Z_RLE */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); - - n = wsize; -#ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); -#endif - more += wsize; - } - if (s->strm->avail_in == 0) return; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead >= MIN_MATCH) { - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK_ONLY(s, eof) { \ - _tr_flush_block(s, (s->block_start >= 0L ? \ - (charf *)&s->window[(unsigned)s->block_start] : \ - (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (eof)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, eof) { \ - FLUSH_BLOCK_ONLY(s, eof); \ - if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ -} - -/* =========================================================================== - * Copy without compression as much as possible from the input stream, return - * the current block state. - * This function does not insert new strings in the dictionary since - * uncompressible data is probably not useful. This function is used - * only for the level=0 compression option. - * NOTE: this function should be optimized to avoid extra copying from - * window to pending_buf. - */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited - * to pending_buf_size, and each stored block has a 5 byte header: - */ - ulg max_block_size = 0xffff; - ulg max_start; - - if (max_block_size > s->pending_buf_size - 5) { - max_block_size = s->pending_buf_size - 5; - } - - /* Copy as much as possible from input to output: */ - for (;;) { - /* Fill the window as much as possible: */ - if (s->lookahead <= 1) { - - Assert(s->strstart < s->w_size+MAX_DIST(s) || - s->block_start >= (long)s->w_size, "slide too late"); - - fill_window(s); - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; - - if (s->lookahead == 0) break; /* flush the current block */ - } - Assert(s->block_start >= 0L, "block gone"); - - s->strstart += s->lookahead; - s->lookahead = 0; - - /* Emit a stored block if pending_buf will be full: */ - max_start = s->block_start + max_block_size; - if (s->strstart == 0 || (ulg)s->strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s->lookahead = (uInt)(s->strstart - max_start); - s->strstart = (uInt)max_start; - FLUSH_BLOCK(s, 0); - } - /* Flush if we may have to slide, otherwise block_start may become - * negative and the data will be gone: - */ - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { - FLUSH_BLOCK(s, 0); - } - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -/* =========================================================================== - * Compress as much as possible from the input stream, return the current - * block state. - * This function does not perform lazy evaluation of matches and inserts - * new strings in the dictionary only for unmatched strings or for short - * matches. It is used only for the fast compression options. - */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ -#ifdef FASTEST - if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) || - (s->strategy == Z_RLE && s->strstart - hash_head == 1)) { - s->match_length = longest_match_fast (s, hash_head); - } -#else - if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { - s->match_length = longest_match (s, hash_head); - } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { - s->match_length = longest_match_fast (s, hash_head); - } -#endif - /* longest_match() or longest_match_fast() sets match_start */ - } - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->match_start, s->match_length); - - _tr_tally_dist(s, s->strstart - s->match_start, - s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ -#ifndef FASTEST - if (s->match_length <= s->max_insert_length && - s->lookahead >= MIN_MATCH) { - s->match_length--; /* string at strstart already in table */ - do { - s->strstart++; - INSERT_STRING(s, s->strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--s->match_length != 0); - s->strstart++; - } else -#endif - { - s->strstart += s->match_length; - s->match_length = 0; - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -#ifndef FASTEST -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* head of hash chain */ - int bflush; /* set if current block must be flushed */ - - /* Process the input block. */ - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - */ - s->prev_length = s->match_length, s->prev_match = s->match_start; - s->match_length = MIN_MATCH-1; - - if (hash_head != NIL && s->prev_length < s->max_lazy_match && - s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { - s->match_length = longest_match (s, hash_head); - } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { - s->match_length = longest_match_fast (s, hash_head); - } - /* longest_match() or longest_match_fast() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED -#if TOO_FAR <= 32767 - || (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR) -#endif - )) { - - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - s->match_length = MIN_MATCH-1; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - - check_match(s, s->strstart-1, s->prev_match, s->prev_length); - - _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not - * enough lookahead, the last two strings are not inserted in - * the hash table. - */ - s->lookahead -= s->prev_length-1; - s->prev_length -= 2; - do { - if (++s->strstart <= max_insert) { - INSERT_STRING(s, s->strstart, hash_head); - } - } while (--s->prev_length != 0); - s->match_available = 0; - s->match_length = MIN_MATCH-1; - s->strstart++; - - if (bflush) FLUSH_BLOCK(s, 0); - - } else if (s->match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - if (bflush) { - FLUSH_BLOCK_ONLY(s, 0); - } - s->strstart++; - s->lookahead--; - if (s->strm->avail_out == 0) return need_more; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - s->match_available = 1; - s->strstart++; - s->lookahead--; - } - } - Assert (flush != Z_NO_FLUSH, "no flush?"); - if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - s->match_available = 0; - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} -#endif /* FASTEST */ - -#if 0 -/* =========================================================================== - * For Z_RLE, simply look for runs of bytes, generate matches only of distance - * one. Do not maintain a hash table. (It will be regenerated if this run of - * deflate switches away from Z_RLE.) - */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - uInt run; /* length of run */ - uInt max; /* maximum length of run */ - uInt prev; /* byte at distance one to match */ - Bytef *scan; /* scan for end of run */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the longest encodable run. - */ - if (s->lookahead < MAX_MATCH) { - fill_window(s); - if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* See how many times the previous byte repeats */ - run = 0; - if (s->strstart > 0) { /* if there is a previous byte, that is */ - max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH; - scan = s->window + s->strstart - 1; - prev = *scan++; - do { - if (*scan++ != prev) - break; - } while (++run < max); - } - - /* Emit match if have run of MIN_MATCH or longer, else emit literal */ - if (run >= MIN_MATCH) { - check_match(s, s->strstart, s->strstart - 1, run); - _tr_tally_dist(s, 1, run - MIN_MATCH, bflush); - s->lookahead -= run; - s->strstart += run; - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} -#endif diff --git a/sourcepawn/jit/zlib/deflate.h b/sourcepawn/jit/zlib/deflate.h deleted file mode 100644 index 222c53e0..00000000 --- a/sourcepawn/jit/zlib/deflate.h +++ /dev/null @@ -1,331 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-2004 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef DEFLATE_H -#define DEFLATE_H - -#include "zutil.h" - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer creation by deflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip encoding - should be left enabled. */ -#ifndef NO_GZIP -# define GZIP -#endif - -/* =========================================================================== - * Internal compression state. - */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define INIT_STATE 42 -#define EXTRA_STATE 69 -#define NAME_STATE 73 -#define COMMENT_STATE 91 -#define HCRC_STATE 103 -#define BUSY_STATE 113 -#define FINISH_STATE 666 -/* Stream status */ - - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data_s { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} FAR ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -typedef struct static_tree_desc_s static_tree_desc; - -typedef struct tree_desc_s { - ct_data *dyn_tree; /* the dynamic tree */ - int max_code; /* largest code with non zero frequency */ - static_tree_desc *stat_desc; /* the corresponding static tree */ -} FAR tree_desc; - -typedef ush Pos; -typedef Pos FAR Posf; -typedef unsigned IPos; - -/* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. IPos is used only for parameter passing. - */ - -typedef struct internal_state { - z_streamp strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - Bytef *pending_buf; /* output still pending */ - ulg pending_buf_size; /* size of pending_buf */ - Bytef *pending_out; /* next pending byte to output to the stream */ - uInt pending; /* nb of bytes in the pending buffer */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - gz_headerp gzhead; /* gzip header information to write */ - uInt gzindex; /* where in extra, name, or comment */ - Byte method; /* STORED (for zip only) or DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ - - /* used by deflate.c: */ - - uInt w_size; /* LZ77 window size (32K by default) */ - uInt w_bits; /* log2(w_size) (8..16) */ - uInt w_mask; /* w_size - 1 */ - - Bytef *window; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. Also, it limits - * the window size to 64K, which is quite useful on MSDOS. - * To do: use the user input buffer as sliding window. - */ - - ulg window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - Posf *prev; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - Posf *head; /* Heads of the hash chains or NIL. */ - - uInt ins_h; /* hash index of string to be inserted */ - uInt hash_size; /* number of elements in hash table */ - uInt hash_bits; /* log2(hash_size) */ - uInt hash_mask; /* hash_size-1 */ - - uInt hash_shift; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to supress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *l_buf; /* buffer for literals or lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - int last_eob_len; /* bit length of EOB code for last block */ - -#ifdef DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - - /* in trees.c */ -void _tr_init OF((deflate_state *s)); -int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); -void _tr_align OF((deflate_state *s)); -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); - -#define d_code(dist) \ - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never - * used. - */ - -#ifndef DEBUG -/* Inline versions of _tr_tally for speed: */ - -#if defined(GEN_TREES_H) || !defined(STDC) - extern uch _length_code[]; - extern uch _dist_code[]; -#else - extern const uch _length_code[]; - extern const uch _dist_code[]; -#endif - -# define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ - s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -# define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ - ush dist = (distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ - dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ - s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -#else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) -#endif - -#endif /* DEFLATE_H */ diff --git a/sourcepawn/jit/zlib/gzio.c b/sourcepawn/jit/zlib/gzio.c deleted file mode 100644 index 5e20a4aa..00000000 --- a/sourcepawn/jit/zlib/gzio.c +++ /dev/null @@ -1,1026 +0,0 @@ -/* gzio.c -- IO on .gz files - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Compile this file with -DNO_GZCOMPRESS to avoid the compression code. - */ - -/* @(#) $Id$ */ - -#include - -#include "zutil.h" - -#ifdef NO_DEFLATE /* for compatibility with old definition */ -# define NO_GZCOMPRESS -#endif - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -#ifndef Z_BUFSIZE -# ifdef MAXSEG_64K -# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ -# else -# define Z_BUFSIZE 16384 -# endif -#endif -#ifndef Z_PRINTF_BUFSIZE -# define Z_PRINTF_BUFSIZE 4096 -#endif - -#ifdef __MVS__ -# pragma map (fdopen , "\174\174FDOPEN") - FILE *fdopen(int, const char *); -#endif - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern void free OF((voidpf ptr)); -#endif - -#define ALLOC(size) malloc(size) -#define TRYFREE(p) {if (p) free(p);} - -static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ - -/* gzip flag byte */ -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define RESERVED 0xE0 /* bits 5..7: reserved */ - -typedef struct gz_stream { - z_stream stream; - int z_err; /* error code for last stream operation */ - int z_eof; /* set if end of input file */ - FILE *file; /* .gz file */ - Byte *inbuf; /* input buffer */ - Byte *outbuf; /* output buffer */ - uLong crc; /* crc32 of uncompressed data */ - char *msg; /* error message */ - char *path; /* path name for debugging only */ - int transparent; /* 1 if input file is not a .gz file */ - char mode; /* 'w' or 'r' */ - z_off_t start; /* start of compressed data in file (header skipped) */ - z_off_t in; /* bytes into deflate or inflate */ - z_off_t out; /* bytes out of deflate or inflate */ - int back; /* one character push-back */ - int last; /* true if push-back is last character */ -} gz_stream; - - -local gzFile gz_open OF((const char *path, const char *mode, int fd)); -local int do_flush OF((gzFile file, int flush)); -local int get_byte OF((gz_stream *s)); -local void check_header OF((gz_stream *s)); -local int destroy OF((gz_stream *s)); -local void putLong OF((FILE *file, uLong x)); -local uLong getLong OF((gz_stream *s)); - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb"). The file is given either by file descriptor - or path name (if fd == -1). - gz_open returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). -*/ -local gzFile gz_open (path, mode, fd) - const char *path; - const char *mode; - int fd; -{ - int err; - int level = Z_DEFAULT_COMPRESSION; /* compression level */ - int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ - char *p = (char*)mode; - gz_stream *s; - char fmode[80]; /* copy of mode, without the compression level */ - char *m = fmode; - - if (!path || !mode) return Z_NULL; - - s = (gz_stream *)ALLOC(sizeof(gz_stream)); - if (!s) return Z_NULL; - - s->stream.zalloc = (alloc_func)0; - s->stream.zfree = (free_func)0; - s->stream.opaque = (voidpf)0; - s->stream.next_in = s->inbuf = Z_NULL; - s->stream.next_out = s->outbuf = Z_NULL; - s->stream.avail_in = s->stream.avail_out = 0; - s->file = NULL; - s->z_err = Z_OK; - s->z_eof = 0; - s->in = 0; - s->out = 0; - s->back = EOF; - s->crc = crc32(0L, Z_NULL, 0); - s->msg = NULL; - s->transparent = 0; - - s->path = (char*)ALLOC(strlen(path)+1); - if (s->path == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - strcpy(s->path, path); /* do this early for debugging */ - - s->mode = '\0'; - do { - if (*p == 'r') s->mode = 'r'; - if (*p == 'w' || *p == 'a') s->mode = 'w'; - if (*p >= '0' && *p <= '9') { - level = *p - '0'; - } else if (*p == 'f') { - strategy = Z_FILTERED; - } else if (*p == 'h') { - strategy = Z_HUFFMAN_ONLY; - } else if (*p == 'R') { - strategy = Z_RLE; - } else { - *m++ = *p; /* copy the mode */ - } - } while (*p++ && m != fmode + sizeof(fmode)); - if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; - - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - err = Z_STREAM_ERROR; -#else - err = deflateInit2(&(s->stream), level, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); - /* windowBits is passed < 0 to suppress zlib header */ - - s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); -#endif - if (err != Z_OK || s->outbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } else { - s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); - - err = inflateInit2(&(s->stream), -MAX_WBITS); - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are - * present after the compressed stream. - */ - if (err != Z_OK || s->inbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } - s->stream.avail_out = Z_BUFSIZE; - - errno = 0; - s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode); - - if (s->file == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - if (s->mode == 'w') { - /* Write a very simple .gz header: - */ - fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); - s->start = 10L; - /* We use 10L instead of ftell(s->file) to because ftell causes an - * fflush on some systems. This version of the library doesn't use - * start anyway in write mode, so this initialization is not - * necessary. - */ - } else { - check_header(s); /* skip the .gz header */ - s->start = ftell(s->file) - s->stream.avail_in; - } - - return (gzFile)s; -} - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. -*/ -gzFile ZEXPORT gzopen (path, mode) - const char *path; - const char *mode; -{ - return gz_open (path, mode, -1); -} - -/* =========================================================================== - Associate a gzFile with the file descriptor fd. fd is not dup'ed here - to mimic the behavio(u)r of fdopen. -*/ -gzFile ZEXPORT gzdopen (fd, mode) - int fd; - const char *mode; -{ - char name[46]; /* allow for up to 128-bit integers */ - - if (fd < 0) return (gzFile)Z_NULL; - sprintf(name, "", fd); /* for debugging */ - - return gz_open (name, mode, fd); -} - -/* =========================================================================== - * Update the compression level and strategy - */ -int ZEXPORT gzsetparams (file, level, strategy) - gzFile file; - int level; - int strategy; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - /* Make room to allow flushing */ - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - } - s->stream.avail_out = Z_BUFSIZE; - } - - return deflateParams (&(s->stream), level, strategy); -} - -/* =========================================================================== - Read a byte from a gz_stream; update next_in and avail_in. Return EOF - for end of file. - IN assertion: the stream s has been sucessfully opened for reading. -*/ -local int get_byte(s) - gz_stream *s; -{ - if (s->z_eof) return EOF; - if (s->stream.avail_in == 0) { - errno = 0; - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) s->z_err = Z_ERRNO; - return EOF; - } - s->stream.next_in = s->inbuf; - } - s->stream.avail_in--; - return *(s->stream.next_in)++; -} - -/* =========================================================================== - Check the gzip header of a gz_stream opened for reading. Set the stream - mode to transparent if the gzip magic header is not present; set s->err - to Z_DATA_ERROR if the magic header is present but the rest of the header - is incorrect. - IN assertion: the stream s has already been created sucessfully; - s->stream.avail_in is zero for the first time, but may be non-zero - for concatenated .gz files. -*/ -local void check_header(s) - gz_stream *s; -{ - int method; /* method byte */ - int flags; /* flags byte */ - uInt len; - int c; - - /* Assure two bytes in the buffer so we can peek ahead -- handle case - where first byte of header is at the end of the buffer after the last - gzip segment */ - len = s->stream.avail_in; - if (len < 2) { - if (len) s->inbuf[0] = s->stream.next_in[0]; - errno = 0; - len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file); - if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; - s->stream.avail_in += len; - s->stream.next_in = s->inbuf; - if (s->stream.avail_in < 2) { - s->transparent = s->stream.avail_in; - return; - } - } - - /* Peek ahead to check the gzip magic header */ - if (s->stream.next_in[0] != gz_magic[0] || - s->stream.next_in[1] != gz_magic[1]) { - s->transparent = 1; - return; - } - s->stream.avail_in -= 2; - s->stream.next_in += 2; - - /* Check the rest of the gzip header */ - method = get_byte(s); - flags = get_byte(s); - if (method != Z_DEFLATED || (flags & RESERVED) != 0) { - s->z_err = Z_DATA_ERROR; - return; - } - - /* Discard time, xflags and OS code: */ - for (len = 0; len < 6; len++) (void)get_byte(s); - - if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ - len = (uInt)get_byte(s); - len += ((uInt)get_byte(s))<<8; - /* len is garbage if EOF but the loop below will quit anyway */ - while (len-- != 0 && get_byte(s) != EOF) ; - } - if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ - for (len = 0; len < 2; len++) (void)get_byte(s); - } - s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; -} - - /* =========================================================================== - * Cleanup then free the given gz_stream. Return a zlib error code. - Try freeing in the reverse order of allocations. - */ -local int destroy (s) - gz_stream *s; -{ - int err = Z_OK; - - if (!s) return Z_STREAM_ERROR; - - TRYFREE(s->msg); - - if (s->stream.state != NULL) { - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - err = Z_STREAM_ERROR; -#else - err = deflateEnd(&(s->stream)); -#endif - } else if (s->mode == 'r') { - err = inflateEnd(&(s->stream)); - } - } - if (s->file != NULL && fclose(s->file)) { -#ifdef ESPIPE - if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ -#endif - err = Z_ERRNO; - } - if (s->z_err < 0) err = s->z_err; - - TRYFREE(s->inbuf); - TRYFREE(s->outbuf); - TRYFREE(s->path); - TRYFREE(s); - return err; -} - -/* =========================================================================== - Reads the given number of uncompressed bytes from the compressed file. - gzread returns the number of bytes actually read (0 for end of file). -*/ -int ZEXPORT gzread (file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ - gz_stream *s = (gz_stream*)file; - Bytef *start = (Bytef*)buf; /* starting point for crc computation */ - Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ - - if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; - - if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; - if (s->z_err == Z_STREAM_END) return 0; /* EOF */ - - next_out = (Byte*)buf; - s->stream.next_out = (Bytef*)buf; - s->stream.avail_out = len; - - if (s->stream.avail_out && s->back != EOF) { - *next_out++ = s->back; - s->stream.next_out++; - s->stream.avail_out--; - s->back = EOF; - s->out++; - start++; - if (s->last) { - s->z_err = Z_STREAM_END; - return 1; - } - } - - while (s->stream.avail_out != 0) { - - if (s->transparent) { - /* Copy first the lookahead bytes: */ - uInt n = s->stream.avail_in; - if (n > s->stream.avail_out) n = s->stream.avail_out; - if (n > 0) { - zmemcpy(s->stream.next_out, s->stream.next_in, n); - next_out += n; - s->stream.next_out = next_out; - s->stream.next_in += n; - s->stream.avail_out -= n; - s->stream.avail_in -= n; - } - if (s->stream.avail_out > 0) { - s->stream.avail_out -= - (uInt)fread(next_out, 1, s->stream.avail_out, s->file); - } - len -= s->stream.avail_out; - s->in += len; - s->out += len; - if (len == 0) s->z_eof = 1; - return (int)len; - } - if (s->stream.avail_in == 0 && !s->z_eof) { - - errno = 0; - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) { - s->z_err = Z_ERRNO; - break; - } - } - s->stream.next_in = s->inbuf; - } - s->in += s->stream.avail_in; - s->out += s->stream.avail_out; - s->z_err = inflate(&(s->stream), Z_NO_FLUSH); - s->in -= s->stream.avail_in; - s->out -= s->stream.avail_out; - - if (s->z_err == Z_STREAM_END) { - /* Check CRC and original size */ - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - start = s->stream.next_out; - - if (getLong(s) != s->crc) { - s->z_err = Z_DATA_ERROR; - } else { - (void)getLong(s); - /* The uncompressed length returned by above getlong() may be - * different from s->out in case of concatenated .gz files. - * Check for such files: - */ - check_header(s); - if (s->z_err == Z_OK) { - inflateReset(&(s->stream)); - s->crc = crc32(0L, Z_NULL, 0); - } - } - } - if (s->z_err != Z_OK || s->z_eof) break; - } - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - - if (len == s->stream.avail_out && - (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)) - return -1; - return (int)(len - s->stream.avail_out); -} - - -/* =========================================================================== - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ -int ZEXPORT gzgetc(file) - gzFile file; -{ - unsigned char c; - - return gzread(file, &c, 1) == 1 ? c : -1; -} - - -/* =========================================================================== - Push one byte back onto the stream. -*/ -int ZEXPORT gzungetc(c, file) - int c; - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF; - s->back = c; - s->out--; - s->last = (s->z_err == Z_STREAM_END); - if (s->last) s->z_err = Z_OK; - s->z_eof = 0; - return c; -} - - -/* =========================================================================== - Reads bytes from the compressed file until len-1 characters are - read, or a newline character is read and transferred to buf, or an - end-of-file condition is encountered. The string is then terminated - with a null character. - gzgets returns buf, or Z_NULL in case of error. - - The current implementation is not optimized at all. -*/ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ - char *b = buf; - if (buf == Z_NULL || len <= 0) return Z_NULL; - - while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ; - *buf = '\0'; - return b == buf && len > 0 ? Z_NULL : b; -} - - -#ifndef NO_GZCOMPRESS -/* =========================================================================== - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of bytes actually written (0 in case of error). -*/ -int ZEXPORT gzwrite (file, buf, len) - gzFile file; - voidpc buf; - unsigned len; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.next_in = (Bytef*)buf; - s->stream.avail_in = len; - - while (s->stream.avail_in != 0) { - - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - break; - } - s->stream.avail_out = Z_BUFSIZE; - } - s->in += s->stream.avail_in; - s->out += s->stream.avail_out; - s->z_err = deflate(&(s->stream), Z_NO_FLUSH); - s->in -= s->stream.avail_in; - s->out -= s->stream.avail_out; - if (s->z_err != Z_OK) break; - } - s->crc = crc32(s->crc, (const Bytef *)buf, len); - - return (int)(len - s->stream.avail_in); -} - - -/* =========================================================================== - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). -*/ -#ifdef STDC -#include - -int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) -{ - char buf[Z_PRINTF_BUFSIZE]; - va_list va; - int len; - - buf[sizeof(buf) - 1] = 0; - va_start(va, format); -#ifdef NO_vsnprintf -# ifdef HAS_vsprintf_void - (void)vsprintf(buf, format, va); - va_end(va); - for (len = 0; len < sizeof(buf); len++) - if (buf[len] == 0) break; -# else - len = vsprintf(buf, format, va); - va_end(va); -# endif -#else -# ifdef HAS_vsnprintf_void - (void)vsnprintf(buf, sizeof(buf), format, va); - va_end(va); - len = strlen(buf); -# else - len = vsnprintf(buf, sizeof(buf), format, va); - va_end(va); -# endif -#endif - if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0) - return 0; - return gzwrite(file, buf, (unsigned)len); -} -#else /* not ANSI C */ - -int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ - char buf[Z_PRINTF_BUFSIZE]; - int len; - - buf[sizeof(buf) - 1] = 0; -#ifdef NO_snprintf -# ifdef HAS_sprintf_void - sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - for (len = 0; len < sizeof(buf); len++) - if (buf[len] == 0) break; -# else - len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#else -# ifdef HAS_snprintf_void - snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - len = strlen(buf); -# else - len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#endif - if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0) - return 0; - return gzwrite(file, buf, len); -} -#endif - -/* =========================================================================== - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ - unsigned char cc = (unsigned char) c; /* required for big endian systems */ - - return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; -} - - -/* =========================================================================== - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ -int ZEXPORT gzputs(file, s) - gzFile file; - const char *s; -{ - return gzwrite(file, (char*)s, (unsigned)strlen(s)); -} - - -/* =========================================================================== - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. -*/ -local int do_flush (file, flush) - gzFile file; - int flush; -{ - uInt len; - int done = 0; - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.avail_in = 0; /* should be zero already anyway */ - - for (;;) { - len = Z_BUFSIZE - s->stream.avail_out; - - if (len != 0) { - if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { - s->z_err = Z_ERRNO; - return Z_ERRNO; - } - s->stream.next_out = s->outbuf; - s->stream.avail_out = Z_BUFSIZE; - } - if (done) break; - s->out += s->stream.avail_out; - s->z_err = deflate(&(s->stream), flush); - s->out -= s->stream.avail_out; - - /* Ignore the second of two consecutive flushes: */ - if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; - - /* deflate has finished flushing only when it hasn't used up - * all the available space in the output buffer: - */ - done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); - - if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; - } - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} - -int ZEXPORT gzflush (file, flush) - gzFile file; - int flush; -{ - gz_stream *s = (gz_stream*)file; - int err = do_flush (file, flush); - - if (err) return err; - fflush(s->file); - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} -#endif /* NO_GZCOMPRESS */ - -/* =========================================================================== - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error. - SEEK_END is not implemented, returns error. - In this version of the library, gzseek can be extremely slow. -*/ -z_off_t ZEXPORT gzseek (file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || whence == SEEK_END || - s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { - return -1L; - } - - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - return -1L; -#else - if (whence == SEEK_SET) { - offset -= s->in; - } - if (offset < 0) return -1L; - - /* At this point, offset is the number of zero bytes to write. */ - if (s->inbuf == Z_NULL) { - s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ - if (s->inbuf == Z_NULL) return -1L; - zmemzero(s->inbuf, Z_BUFSIZE); - } - while (offset > 0) { - uInt size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (uInt)offset; - - size = gzwrite(file, s->inbuf, size); - if (size == 0) return -1L; - - offset -= size; - } - return s->in; -#endif - } - /* Rest of function is for reading only */ - - /* compute absolute position */ - if (whence == SEEK_CUR) { - offset += s->out; - } - if (offset < 0) return -1L; - - if (s->transparent) { - /* map to fseek */ - s->back = EOF; - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; - - s->in = s->out = offset; - return offset; - } - - /* For a negative seek, rewind and use positive seek */ - if (offset >= s->out) { - offset -= s->out; - } else if (gzrewind(file) < 0) { - return -1L; - } - /* offset is now the number of bytes to skip. */ - - if (offset != 0 && s->outbuf == Z_NULL) { - s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); - if (s->outbuf == Z_NULL) return -1L; - } - if (offset && s->back != EOF) { - s->back = EOF; - s->out++; - offset--; - if (s->last) s->z_err = Z_STREAM_END; - } - while (offset > 0) { - int size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (int)offset; - - size = gzread(file, s->outbuf, (uInt)size); - if (size <= 0) return -1L; - offset -= size; - } - return s->out; -} - -/* =========================================================================== - Rewinds input file. -*/ -int ZEXPORT gzrewind (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r') return -1; - - s->z_err = Z_OK; - s->z_eof = 0; - s->back = EOF; - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - s->crc = crc32(0L, Z_NULL, 0); - if (!s->transparent) (void)inflateReset(&s->stream); - s->in = 0; - s->out = 0; - return fseek(s->file, s->start, SEEK_SET); -} - -/* =========================================================================== - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. -*/ -z_off_t ZEXPORT gztell (file) - gzFile file; -{ - return gzseek(file, 0L, SEEK_CUR); -} - -/* =========================================================================== - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ -int ZEXPORT gzeof (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - /* With concatenated compressed files that can have embedded - * crc trailers, z_eof is no longer the only/best indicator of EOF - * on a gz_stream. Handle end-of-stream error explicitly here. - */ - if (s == NULL || s->mode != 'r') return 0; - if (s->z_eof) return 1; - return s->z_err == Z_STREAM_END; -} - -/* =========================================================================== - Returns 1 if reading and doing so transparently, otherwise zero. -*/ -int ZEXPORT gzdirect (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r') return 0; - return s->transparent; -} - -/* =========================================================================== - Outputs a long in LSB order to the given file -*/ -local void putLong (file, x) - FILE *file; - uLong x; -{ - int n; - for (n = 0; n < 4; n++) { - fputc((int)(x & 0xff), file); - x >>= 8; - } -} - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets z_err in case - of error. -*/ -local uLong getLong (s) - gz_stream *s; -{ - uLong x = (uLong)get_byte(s); - int c; - - x += ((uLong)get_byte(s))<<8; - x += ((uLong)get_byte(s))<<16; - c = get_byte(s); - if (c == EOF) s->z_err = Z_DATA_ERROR; - x += ((uLong)c)<<24; - return x; -} - -/* =========================================================================== - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. -*/ -int ZEXPORT gzclose (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL) return Z_STREAM_ERROR; - - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - return Z_STREAM_ERROR; -#else - if (do_flush (file, Z_FINISH) != Z_OK) - return destroy((gz_stream*)file); - - putLong (s->file, s->crc); - putLong (s->file, (uLong)(s->in & 0xffffffff)); -#endif - } - return destroy((gz_stream*)file); -} - -#ifdef STDC -# define zstrerror(errnum) strerror(errnum) -#else -# define zstrerror(errnum) "" -#endif - -/* =========================================================================== - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ -const char * ZEXPORT gzerror (file, errnum) - gzFile file; - int *errnum; -{ - char *m; - gz_stream *s = (gz_stream*)file; - - if (s == NULL) { - *errnum = Z_STREAM_ERROR; - return (const char*)ERR_MSG(Z_STREAM_ERROR); - } - *errnum = s->z_err; - if (*errnum == Z_OK) return (const char*)""; - - m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); - - if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); - - TRYFREE(s->msg); - s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); - if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR); - strcpy(s->msg, s->path); - strcat(s->msg, ": "); - strcat(s->msg, m); - return (const char*)s->msg; -} - -/* =========================================================================== - Clear the error and end-of-file flags, and do the same for the real file. -*/ -void ZEXPORT gzclearerr (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL) return; - if (s->z_err != Z_STREAM_END) s->z_err = Z_OK; - s->z_eof = 0; - clearerr(s->file); -} diff --git a/sourcepawn/jit/zlib/infback.c b/sourcepawn/jit/zlib/infback.c deleted file mode 100644 index 0056928e..00000000 --- a/sourcepawn/jit/zlib/infback.c +++ /dev/null @@ -1,624 +0,0 @@ -/* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - This code is largely copied from inflate.c. Normally either infback.o or - inflate.o would be linked into an application--not both. The interface - with inffast.c is retained so that optimized assembler-coded versions of - inflate_fast() can be used with either inflate.c or infback.c. - */ - -#include -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - -/* - strm provides memory allocation functions in zalloc and zfree, or - Z_NULL to use the library memory allocation functions. - - windowBits is in the range 8..15, and window is a user-supplied - window and output buffer that is 2**windowBits bytes. - */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL || window == Z_NULL || - windowBits < 8 || windowBits > 15) - return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state FAR *)ZALLOC(strm, 1, - sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->dmax = 32768U; - state->wbits = windowBits; - state->wsize = 1U << windowBits; - state->window = window; - state->write = 0; - state->whave = 0; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -/* Macros for inflateBack(): */ - -/* Load returned state from inflate_fast() */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Set state from registers for inflate_fast() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Assure that some input is available. If input is requested, but denied, - then return a Z_BUF_ERROR from inflateBack(). */ -#define PULL() \ - do { \ - if (have == 0) { \ - have = in(in_desc, &next); \ - if (have == 0) { \ - next = Z_NULL; \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflateBack() - with an error if there is no input available. */ -#define PULLBYTE() \ - do { \ - PULL(); \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflateBack() with - an error. */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Assure that some output space is available, by writing out the window - if it's full. If the write fails, return from inflateBack() with a - Z_BUF_ERROR. */ -#define ROOM() \ - do { \ - if (left == 0) { \ - put = state->window; \ - left = state->wsize; \ - state->whave = left; \ - if (out(out_desc, put, left)) { \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* - strm provides the memory allocation functions and window buffer on input, - and provides information on the unused input on return. For Z_DATA_ERROR - returns, strm will also provide an error message. - - in() and out() are the call-back input and output functions. When - inflateBack() needs more input, it calls in(). When inflateBack() has - filled the window with output, or when it completes with data in the - window, it calls out() to write out the data. The application must not - change the provided input until in() is called again or inflateBack() - returns. The application must not change the window/output buffer until - inflateBack() returns. - - in() and out() are called with a descriptor parameter provided in the - inflateBack() call. This parameter can be a structure that provides the - information required to do the read or write, as well as accumulated - information on the input and output such as totals and check values. - - in() should return zero on failure. out() should return non-zero on - failure. If either in() or out() fails, than inflateBack() returns a - Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it - was in() or out() that caused in the error. Otherwise, inflateBack() - returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format - error, or Z_MEM_ERROR if it could not allocate memory for the state. - inflateBack() can also return Z_STREAM_ERROR if the input parameters - are not correct, i.e. strm is Z_NULL or the state was not initialized. - */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ - struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code this; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - /* Check that the strm exists and that the state was initialized */ - if (strm == Z_NULL || strm->state == Z_NULL) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* Reset the state */ - strm->msg = Z_NULL; - state->mode = TYPE; - state->last = 0; - state->whave = 0; - next = strm->next_in; - have = next != Z_NULL ? strm->avail_in : 0; - hold = 0; - bits = 0; - put = state->window; - left = state->wsize; - - /* Inflate until end of block marked as last */ - for (;;) - switch (state->mode) { - case TYPE: - /* determine and dispatch block type */ - if (state->last) { - BYTEBITS(); - state->mode = DONE; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - - case STORED: - /* get and verify stored block length */ - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - - /* copy stored block from input to output */ - while (state->length != 0) { - copy = state->length; - PULL(); - ROOM(); - if (copy > have) copy = have; - if (copy > left) copy = left; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - - case TABLE: - /* get dynamic table entries descriptor */ - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - - /* get code length code lengths (not a typo) */ - state->have = 0; - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - - /* get length and distance code code lengths */ - state->have = 0; - while (state->have < state->nlen + state->ndist) { - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.val < 16) { - NEEDBITS(this.bits); - DROPBITS(this.bits); - state->lens[state->have++] = this.val; - } - else { - if (this.val == 16) { - NEEDBITS(this.bits + 2); - DROPBITS(this.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = (unsigned)(state->lens[state->have - 1]); - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (this.val == 17) { - NEEDBITS(this.bits + 3); - DROPBITS(this.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(this.bits + 7); - DROPBITS(this.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* build code tables */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - - case LEN: - /* use inflate_fast() if we have enough input and output */ - if (have >= 6 && left >= 258) { - RESTORE(); - if (state->whave < state->wsize) - state->whave = state->wsize - left; - inflate_fast(strm, state->wsize); - LOAD(); - break; - } - - /* get a literal, length, or end-of-block code */ - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.op && (this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - state->length = (unsigned)this.val; - - /* process literal */ - if (this.op == 0) { - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - ROOM(); - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - } - - /* process end of block */ - if (this.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - - /* invalid code */ - if (this.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - - /* length code -- get extra bits, if any */ - state->extra = (unsigned)(this.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - - /* get distance code */ - for (;;) { - this = state->distcode[BITS(state->distbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if ((this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - if (this.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)this.val; - - /* get distance extra bits, if any */ - state->extra = (unsigned)(this.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } - if (state->offset > state->wsize - (state->whave < state->wsize ? - left : 0)) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - - /* copy match from window to output */ - do { - ROOM(); - copy = state->wsize - state->offset; - if (copy < left) { - from = put + copy; - copy = left - copy; - } - else { - from = put - state->offset; - copy = left; - } - if (copy > state->length) copy = state->length; - state->length -= copy; - left -= copy; - do { - *put++ = *from++; - } while (--copy); - } while (state->length != 0); - break; - - case DONE: - /* inflate stream terminated properly -- write leftover output */ - ret = Z_STREAM_END; - if (left < state->wsize) { - if (out(out_desc, state->window, state->wsize - left)) - ret = Z_BUF_ERROR; - } - goto inf_leave; - - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - - default: /* can't happen, but makes compilers happy */ - ret = Z_STREAM_ERROR; - goto inf_leave; - } - - /* Return unused input */ - inf_leave: - strm->next_in = next; - strm->avail_in = have; - return ret; -} - -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} diff --git a/sourcepawn/jit/zlib/inffast.c b/sourcepawn/jit/zlib/inffast.c deleted file mode 100644 index 20ef523d..00000000 --- a/sourcepawn/jit/zlib/inffast.c +++ /dev/null @@ -1,319 +0,0 @@ -/* inffast.c -- fast decoding - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifndef ASMINF - -/* Allow machine dependent optimization for post-increment or pre-increment. - Based on testing to date, - Pre-increment preferred for: - - PowerPC G3 (Adler) - - MIPS R5000 (Randers-Pehrson) - Post-increment preferred for: - - none - No measurable difference: - - Pentium III (Anderson) - - M68060 (Nikl) - */ -#ifdef POSTINC -# define OFF 0 -# define PUP(a) *(a)++ -#else -# define OFF 1 -# define PUP(a) *++(a) -#endif - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state->mode == LEN - strm->avail_in >= 6 - strm->avail_out >= 258 - start >= strm->avail_out - state->bits < 8 - - On return, state->mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm->avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for - output space. - */ -void inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ - struct inflate_state FAR *state; - unsigned char FAR *in; /* local strm->next_in */ - unsigned char FAR *last; /* while in < last, enough input available */ - unsigned char FAR *out; /* local strm->next_out */ - unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ - unsigned char FAR *end; /* while out < end, enough space available */ -#ifdef INFLATE_STRICT - unsigned dmax; /* maximum distance from zlib header */ -#endif - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned write; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ - unsigned long hold; /* local strm->hold */ - unsigned bits; /* local strm->bits */ - code const FAR *lcode; /* local strm->lencode */ - code const FAR *dcode; /* local strm->distcode */ - unsigned lmask; /* mask for first level of length codes */ - unsigned dmask; /* mask for first level of distance codes */ - code this; /* retrieved table entry */ - unsigned op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - unsigned len; /* match length, unused bytes */ - unsigned dist; /* match distance */ - unsigned char FAR *from; /* where to copy match from */ - - /* copy state to local variables */ - state = (struct inflate_state FAR *)strm->state; - in = strm->next_in - OFF; - last = in + (strm->avail_in - 5); - out = strm->next_out - OFF; - beg = out - (start - strm->avail_out); - end = out + (strm->avail_out - 257); -#ifdef INFLATE_STRICT - dmax = state->dmax; -#endif - wsize = state->wsize; - whave = state->whave; - write = state->write; - window = state->window; - hold = state->hold; - bits = state->bits; - lcode = state->lencode; - dcode = state->distcode; - lmask = (1U << state->lenbits) - 1; - dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - do { - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - this = lcode[hold & lmask]; - dolen: - op = (unsigned)(this.bits); - hold >>= op; - bits -= op; - op = (unsigned)(this.op); - if (op == 0) { /* literal */ - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - PUP(out) = (unsigned char)(this.val); - } - else if (op & 16) { /* length base */ - len = (unsigned)(this.val); - op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - len += (unsigned)hold & ((1U << op) - 1); - hold >>= op; - bits -= op; - } - Tracevv((stderr, "inflate: length %u\n", len)); - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - this = dcode[hold & dmask]; - dodist: - op = (unsigned)(this.bits); - hold >>= op; - bits -= op; - op = (unsigned)(this.op); - if (op & 16) { /* distance base */ - dist = (unsigned)(this.val); - op &= 15; /* number of extra bits */ - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - } - dist += (unsigned)hold & ((1U << op) - 1); -#ifdef INFLATE_STRICT - if (dist > dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - hold >>= op; - bits -= op; - Tracevv((stderr, "inflate: distance %u\n", dist)); - op = (unsigned)(out - beg); /* max distance in output */ - if (dist > op) { /* see if copy from window */ - op = dist - op; /* distance back in window */ - if (op > whave) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - from = window - OFF; - if (write == 0) { /* very common case */ - from += wsize - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - else if (write < op) { /* wrap around window */ - from += wsize + write - op; - op -= write; - if (op < len) { /* some from end of window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = window - OFF; - if (write < len) { /* some from start of window */ - op = write; - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - } - else { /* contiguous in window */ - from += write - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - while (len > 2) { - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - else { - from = out - dist; /* copy direct from output */ - do { /* minimum length is three */ - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } while (len > 2); - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - } - else if ((op & 64) == 0) { /* 2nd level distance code */ - this = dcode[this.val + (hold & ((1U << op) - 1))]; - goto dodist; - } - else { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - } - else if ((op & 64) == 0) { /* 2nd level length code */ - this = lcode[this.val + (hold & ((1U << op) - 1))]; - goto dolen; - } - else if (op & 32) { /* end-of-block */ - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - else { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - } while (in < last && out < end); - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - len = bits >> 3; - in -= len; - bits -= len << 3; - hold &= (1U << bits) - 1; - - /* update state and return */ - strm->next_in = in + OFF; - strm->next_out = out + OFF; - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); - strm->avail_out = (unsigned)(out < end ? - 257 + (end - out) : 257 - (out - end)); - state->hold = hold; - state->bits = bits; - return; -} - -/* - inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): - - Using bit fields for code structure - - Different op definition to avoid & for extra bits (do & for table bits) - - Three separate decoding do-loops for direct, window, and write == 0 - - Special case for distance > 1 copies to do overlapped load and store copy - - Explicit branch predictions (based on measured branch probabilities) - - Deferring match copy and interspersed it with decoding subsequent codes - - Swapping literal/length else - - Swapping window/direct else - - Larger unrolled copy loops (three is about right) - - Moving len -= 3 statement into middle of loop - */ - -#endif /* !ASMINF */ diff --git a/sourcepawn/jit/zlib/inffast.h b/sourcepawn/jit/zlib/inffast.h deleted file mode 100644 index 614fa787..00000000 --- a/sourcepawn/jit/zlib/inffast.h +++ /dev/null @@ -1,11 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2003 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -void inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/sourcepawn/jit/zlib/inffixed.h b/sourcepawn/jit/zlib/inffixed.h deleted file mode 100644 index 423d5c5b..00000000 --- a/sourcepawn/jit/zlib/inffixed.h +++ /dev/null @@ -1,94 +0,0 @@ - /* inffixed.h -- table for decoding fixed codes - * Generated automatically by makefixed(). - */ - - /* WARNING: this file should *not* be used by applications. It - is part of the implementation of the compression library and - is subject to change. Applications should only use zlib.h. - */ - - static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} - }; - - static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} - }; diff --git a/sourcepawn/jit/zlib/inflate.c b/sourcepawn/jit/zlib/inflate.c deleted file mode 100644 index f4606b62..00000000 --- a/sourcepawn/jit/zlib/inflate.c +++ /dev/null @@ -1,1369 +0,0 @@ -/* inflate.c -- zlib decompression - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * Change history: - * - * 1.2.beta0 24 Nov 2002 - * - First version -- complete rewrite of inflate to simplify code, avoid - * creation of window when not needed, minimize use of window when it is - * needed, make inffast.c even faster, implement gzip decoding, and to - * improve code readability and style over the previous zlib inflate code - * - * 1.2.beta1 25 Nov 2002 - * - Use pointers for available input and output checking in inffast.c - * - Remove input and output counters in inffast.c - * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 - * - Remove unnecessary second byte pull from length extra in inffast.c - * - Unroll direct copy to three copies per loop in inffast.c - * - * 1.2.beta2 4 Dec 2002 - * - Change external routine names to reduce potential conflicts - * - Correct filename to inffixed.h for fixed tables in inflate.c - * - Make hbuf[] unsigned char to match parameter type in inflate.c - * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) - * to avoid negation problem on Alphas (64 bit) in inflate.c - * - * 1.2.beta3 22 Dec 2002 - * - Add comments on state->bits assertion in inffast.c - * - Add comments on op field in inftrees.h - * - Fix bug in reuse of allocated window after inflateReset() - * - Remove bit fields--back to byte structure for speed - * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths - * - Change post-increments to pre-increments in inflate_fast(), PPC biased? - * - Add compile time option, POSTINC, to use post-increments instead (Intel?) - * - Make MATCH copy in inflate() much faster for when inflate_fast() not used - * - Use local copies of stream next and avail values, as well as local bit - * buffer and bit count in inflate()--for speed when inflate_fast() not used - * - * 1.2.beta4 1 Jan 2003 - * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings - * - Move a comment on output buffer sizes from inffast.c to inflate.c - * - Add comments in inffast.c to introduce the inflate_fast() routine - * - Rearrange window copies in inflate_fast() for speed and simplification - * - Unroll last copy for window match in inflate_fast() - * - Use local copies of window variables in inflate_fast() for speed - * - Pull out common write == 0 case for speed in inflate_fast() - * - Make op and len in inflate_fast() unsigned for consistency - * - Add FAR to lcode and dcode declarations in inflate_fast() - * - Simplified bad distance check in inflate_fast() - * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new - * source file infback.c to provide a call-back interface to inflate for - * programs like gzip and unzip -- uses window as output buffer to avoid - * window copying - * - * 1.2.beta5 1 Jan 2003 - * - Improved inflateBack() interface to allow the caller to provide initial - * input in strm. - * - Fixed stored blocks bug in inflateBack() - * - * 1.2.beta6 4 Jan 2003 - * - Added comments in inffast.c on effectiveness of POSTINC - * - Typecasting all around to reduce compiler warnings - * - Changed loops from while (1) or do {} while (1) to for (;;), again to - * make compilers happy - * - Changed type of window in inflateBackInit() to unsigned char * - * - * 1.2.beta7 27 Jan 2003 - * - Changed many types to unsigned or unsigned short to avoid warnings - * - Added inflateCopy() function - * - * 1.2.0 9 Mar 2003 - * - Changed inflateBack() interface to provide separate opaque descriptors - * for the in() and out() functions - * - Changed inflateBack() argument and in_func typedef to swap the length - * and buffer address return values for the input function - * - Check next_in and next_out for Z_NULL on entry to inflate() - * - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. - */ - -#include -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifdef MAKEFIXED -# ifndef BUILDFIXED -# define BUILDFIXED -# endif -#endif - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, unsigned out)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, - unsigned len)); - -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - strm->total_in = strm->total_out = state->total = 0; - strm->msg = Z_NULL; - strm->adler = 1; /* to support ill-conceived Java test suite */ - state->mode = HEAD; - state->last = 0; - state->havedict = 0; - state->dmax = 32768U; - state->head = Z_NULL; - state->wsize = 0; - state->whave = 0; - state->write = 0; - state->hold = 0; - state->bits = 0; - state->lencode = state->distcode = state->next = state->codes; - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; - value &= (1L << bits) - 1; - state->hold += value << state->bits; - state->bits += bits; - return Z_OK; -} - -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL) return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state FAR *) - ZALLOC(strm, 1, sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - if (windowBits < 0) { - state->wrap = 0; - windowBits = -windowBits; - } - else { - state->wrap = (windowBits >> 4) + 1; -#ifdef GUNZIP - if (windowBits < 48) windowBits &= 15; -#endif - } - if (windowBits < 8 || windowBits > 15) { - ZFREE(strm, state); - strm->state = Z_NULL; - return Z_STREAM_ERROR; - } - state->wbits = (unsigned)windowBits; - state->window = Z_NULL; - return inflateReset(strm); -} - -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ - return inflateInit2_(strm, DEF_WBITS, version, stream_size); -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -#ifdef MAKEFIXED -#include - -/* - Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also - defines BUILDFIXED, so the tables are built on the fly. makefixed() writes - those tables to stdout, which would be piped to inffixed.h. A small program - can simply call makefixed to do this: - - void makefixed(void); - - int main(void) - { - makefixed(); - return 0; - } - - Then that can be linked with zlib built with MAKEFIXED defined and run: - - a.out > inffixed.h - */ -void makefixed() -{ - unsigned low, size; - struct inflate_state state; - - fixedtables(&state); - puts(" /* inffixed.h -- table for decoding fixed codes"); - puts(" * Generated automatically by makefixed()."); - puts(" */"); - puts(""); - puts(" /* WARNING: this file should *not* be used by applications."); - puts(" It is part of the implementation of this library and is"); - puts(" subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - size = 1U << 9; - printf(" static const code lenfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 7) == 0) printf("\n "); - printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, - state.lencode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); - size = 1U << 5; - printf("\n static const code distfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 6) == 0) printf("\n "); - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, - state.distcode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); -} -#endif /* MAKEFIXED */ - -/* - Update the window with the last wsize (normally 32K) bytes written before - returning. If window does not exist yet, create it. This is only called - when a window is already in use, or when output has been written during this - inflate call, but the end of the deflate stream has not been reached yet. - It is also called to create a window for dictionary data when a dictionary - is loaded. - - Providing output buffers larger than 32K to inflate() should provide a speed - advantage, since only the last 32K of output is copied to the sliding window - upon return from inflate(), and since all distances after the first 32K of - output will fall in the output data, making match copies simpler and faster. - The advantage may be dependent on the size of the processor's data caches. - */ -local int updatewindow(strm, out) -z_streamp strm; -unsigned out; -{ - struct inflate_state FAR *state; - unsigned copy, dist; - - state = (struct inflate_state FAR *)strm->state; - - /* if it hasn't been done already, allocate space for the window */ - if (state->window == Z_NULL) { - state->window = (unsigned char FAR *) - ZALLOC(strm, 1U << state->wbits, - sizeof(unsigned char)); - if (state->window == Z_NULL) return 1; - } - - /* if window not in use yet, initialize */ - if (state->wsize == 0) { - state->wsize = 1U << state->wbits; - state->write = 0; - state->whave = 0; - } - - /* copy state->wsize or less output bytes into the circular window */ - copy = out - strm->avail_out; - if (copy >= state->wsize) { - zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); - state->write = 0; - state->whave = state->wsize; - } - else { - dist = state->wsize - state->write; - if (dist > copy) dist = copy; - zmemcpy(state->window + state->write, strm->next_out - copy, dist); - copy -= dist; - if (copy) { - zmemcpy(state->window, strm->next_out - copy, copy); - state->write = copy; - state->whave = state->wsize; - } - else { - state->write += dist; - if (state->write == state->wsize) state->write = 0; - if (state->whave < state->wsize) state->whave += dist; - } - } - return 0; -} - -/* Macros for inflate(): */ - -/* check function to use adler32() for zlib or crc32() for gzip */ -#ifdef GUNZIP -# define UPDATE(check, buf, len) \ - (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) -#else -# define UPDATE(check, buf, len) adler32(check, buf, len) -#endif - -/* check macros for header crc */ -#ifdef GUNZIP -# define CRC2(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - check = crc32(check, hbuf, 2); \ - } while (0) - -# define CRC4(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - hbuf[2] = (unsigned char)((word) >> 16); \ - hbuf[3] = (unsigned char)((word) >> 24); \ - check = crc32(check, hbuf, 4); \ - } while (0) -#endif - -/* Load registers with state in inflate() for speed */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Restore state from registers in inflate() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflate() - if there is no input available. */ -#define PULLBYTE() \ - do { \ - if (have == 0) goto inf_leave; \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflate(). */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Reverse the bytes in a 32-bit value */ -#define REVERSE(q) \ - ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - -/* - inflate() uses a state machine to process as much input data and generate as - much output data as possible before returning. The state machine is - structured roughly as follows: - - for (;;) switch (state) { - ... - case STATEn: - if (not enough input data or output space to make progress) - return; - ... make progress ... - state = STATEm; - break; - ... - } - - so when inflate() is called again, the same case is attempted again, and - if the appropriate resources are provided, the machine proceeds to the - next state. The NEEDBITS() macro is usually the way the state evaluates - whether it can proceed or should return. NEEDBITS() does the return if - the requested bits are not available. The typical use of the BITS macros - is: - - NEEDBITS(n); - ... do something with BITS(n) ... - DROPBITS(n); - - where NEEDBITS(n) either returns from inflate() if there isn't enough - input left to load n bits into the accumulator, or it continues. BITS(n) - gives the low n bits in the accumulator. When done, DROPBITS(n) drops - the low n bits off the accumulator. INITBITS() clears the accumulator - and sets the number of available bits to zero. BYTEBITS() discards just - enough bits to put the accumulator on a byte boundary. After BYTEBITS() - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. - - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return - if there is no input available. The decoding of variable length codes uses - PULLBYTE() directly in order to pull just enough bytes to decode the next - code, and no more. - - Some states loop until they get enough input, making sure that enough - state information is maintained to continue the loop where it left off - if NEEDBITS() returns in the loop. For example, want, need, and keep - would all have to actually be part of the saved state in case NEEDBITS() - returns: - - case STATEw: - while (want < need) { - NEEDBITS(n); - keep[want++] = BITS(n); - DROPBITS(n); - } - state = STATEx; - case STATEx: - - As shown above, if the next state is also the next case, then the break - is omitted. - - A state may also return if there is not enough output space available to - complete that state. Those states are copying stored data, writing a - literal byte, and copying a matching string. - - When returning, a "goto inf_leave" is used to update the total counters, - update the check value, and determine whether any progress has been made - during that inflate() call in order to return the proper return code. - Progress is defined as a change in either strm->avail_in or strm->avail_out. - When there is a window, goto inf_leave will update the window with the last - output written. If a goto inf_leave occurs in the middle of decompression - and there is no window currently, goto inf_leave will create one and copy - output to the window for the next call of inflate(). - - In this implementation, the flush parameter of inflate() only affects the - return code (per zlib.h). inflate() always writes as much as possible to - strm->next_out, given the space available and the provided input--the effect - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers - the allocation of and copying into a sliding window until necessary, which - provides the effect documented in zlib.h for Z_FINISH when the entire input - stream available. So the only thing the flush parameter actually does is: - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it - will return Z_BUF_ERROR if it has not reached the end of the stream. - */ - -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ - struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned in, out; /* save starting available input and output */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code this; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ -#ifdef GUNZIP - unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ -#endif - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0)) - return Z_STREAM_ERROR; - - state = (struct inflate_state FAR *)strm->state; - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ - LOAD(); - in = have; - out = left; - ret = Z_OK; - for (;;) - switch (state->mode) { - case HEAD: - if (state->wrap == 0) { - state->mode = TYPEDO; - break; - } - NEEDBITS(16); -#ifdef GUNZIP - if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ - state->check = crc32(0L, Z_NULL, 0); - CRC2(state->check, hold); - INITBITS(); - state->mode = FLAGS; - break; - } - state->flags = 0; /* expect zlib header */ - if (state->head != Z_NULL) - state->head->done = -1; - if (!(state->wrap & 1) || /* check if zlib header allowed */ -#else - if ( -#endif - ((BITS(8) << 8) + (hold >> 8)) % 31) { - strm->msg = (char *)"incorrect header check"; - state->mode = BAD; - break; - } - if (BITS(4) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - DROPBITS(4); - len = BITS(4) + 8; - if (len > state->wbits) { - strm->msg = (char *)"invalid window size"; - state->mode = BAD; - break; - } - state->dmax = 1U << len; - Tracev((stderr, "inflate: zlib header ok\n")); - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = hold & 0x200 ? DICTID : TYPE; - INITBITS(); - break; -#ifdef GUNZIP - case FLAGS: - NEEDBITS(16); - state->flags = (int)(hold); - if ((state->flags & 0xff) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - if (state->flags & 0xe000) { - strm->msg = (char *)"unknown header flags set"; - state->mode = BAD; - break; - } - if (state->head != Z_NULL) - state->head->text = (int)((hold >> 8) & 1); - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = TIME; - case TIME: - NEEDBITS(32); - if (state->head != Z_NULL) - state->head->time = hold; - if (state->flags & 0x0200) CRC4(state->check, hold); - INITBITS(); - state->mode = OS; - case OS: - NEEDBITS(16); - if (state->head != Z_NULL) { - state->head->xflags = (int)(hold & 0xff); - state->head->os = (int)(hold >> 8); - } - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = EXLEN; - case EXLEN: - if (state->flags & 0x0400) { - NEEDBITS(16); - state->length = (unsigned)(hold); - if (state->head != Z_NULL) - state->head->extra_len = (unsigned)hold; - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - } - else if (state->head != Z_NULL) - state->head->extra = Z_NULL; - state->mode = EXTRA; - case EXTRA: - if (state->flags & 0x0400) { - copy = state->length; - if (copy > have) copy = have; - if (copy) { - if (state->head != Z_NULL && - state->head->extra != Z_NULL) { - len = state->head->extra_len - state->length; - zmemcpy(state->head->extra + len, next, - len + copy > state->head->extra_max ? - state->head->extra_max - len : copy); - } - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - state->length -= copy; - } - if (state->length) goto inf_leave; - } - state->length = 0; - state->mode = NAME; - case NAME: - if (state->flags & 0x0800) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->name != Z_NULL && - state->length < state->head->name_max) - state->head->name[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->name = Z_NULL; - state->length = 0; - state->mode = COMMENT; - case COMMENT: - if (state->flags & 0x1000) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->comment != Z_NULL && - state->length < state->head->comm_max) - state->head->comment[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->comment = Z_NULL; - state->mode = HCRC; - case HCRC: - if (state->flags & 0x0200) { - NEEDBITS(16); - if (hold != (state->check & 0xffff)) { - strm->msg = (char *)"header crc mismatch"; - state->mode = BAD; - break; - } - INITBITS(); - } - if (state->head != Z_NULL) { - state->head->hcrc = (int)((state->flags >> 9) & 1); - state->head->done = 1; - } - strm->adler = state->check = crc32(0L, Z_NULL, 0); - state->mode = TYPE; - break; -#endif - case DICTID: - NEEDBITS(32); - strm->adler = state->check = REVERSE(hold); - INITBITS(); - state->mode = DICT; - case DICT: - if (state->havedict == 0) { - RESTORE(); - return Z_NEED_DICT; - } - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = TYPE; - case TYPE: - if (flush == Z_BLOCK) goto inf_leave; - case TYPEDO: - if (state->last) { - BYTEBITS(); - state->mode = CHECK; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - case STORED: - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - state->mode = COPY; - case COPY: - copy = state->length; - if (copy) { - if (copy > have) copy = have; - if (copy > left) copy = left; - if (copy == 0) goto inf_leave; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - break; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - case TABLE: - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - state->have = 0; - state->mode = LENLENS; - case LENLENS: - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - state->have = 0; - state->mode = CODELENS; - case CODELENS: - while (state->have < state->nlen + state->ndist) { - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.val < 16) { - NEEDBITS(this.bits); - DROPBITS(this.bits); - state->lens[state->have++] = this.val; - } - else { - if (this.val == 16) { - NEEDBITS(this.bits + 2); - DROPBITS(this.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = state->lens[state->have - 1]; - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (this.val == 17) { - NEEDBITS(this.bits + 3); - DROPBITS(this.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(this.bits + 7); - DROPBITS(this.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* build code tables */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - case LEN: - if (have >= 6 && left >= 258) { - RESTORE(); - inflate_fast(strm, out); - LOAD(); - break; - } - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.op && (this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - state->length = (unsigned)this.val; - if ((int)(this.op) == 0) { - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - state->mode = LIT; - break; - } - if (this.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - if (this.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - state->extra = (unsigned)(this.op) & 15; - state->mode = LENEXT; - case LENEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - state->mode = DIST; - case DIST: - for (;;) { - this = state->distcode[BITS(state->distbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if ((this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - if (this.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)this.val; - state->extra = (unsigned)(this.op) & 15; - state->mode = DISTEXT; - case DISTEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } -#ifdef INFLATE_STRICT - if (state->offset > state->dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - if (state->offset > state->whave + out - left) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - state->mode = MATCH; - case MATCH: - if (left == 0) goto inf_leave; - copy = out - left; - if (state->offset > copy) { /* copy from window */ - copy = state->offset - copy; - if (copy > state->write) { - copy -= state->write; - from = state->window + (state->wsize - copy); - } - else - from = state->window + (state->write - copy); - if (copy > state->length) copy = state->length; - } - else { /* copy from output */ - from = put - state->offset; - copy = state->length; - } - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = *from++; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; - case LIT: - if (left == 0) goto inf_leave; - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - case CHECK: - if (state->wrap) { - NEEDBITS(32); - out -= left; - strm->total_out += out; - state->total += out; - if (out) - strm->adler = state->check = - UPDATE(state->check, put - out, out); - out = left; - if (( -#ifdef GUNZIP - state->flags ? hold : -#endif - REVERSE(hold)) != state->check) { - strm->msg = (char *)"incorrect data check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: check matches trailer\n")); - } -#ifdef GUNZIP - state->mode = LENGTH; - case LENGTH: - if (state->wrap && state->flags) { - NEEDBITS(32); - if (hold != (state->total & 0xffffffffUL)) { - strm->msg = (char *)"incorrect length check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: length matches trailer\n")); - } -#endif - state->mode = DONE; - case DONE: - ret = Z_STREAM_END; - goto inf_leave; - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: - return Z_STREAM_ERROR; - } - - /* - Return from inflate(), updating the total counts and the check value. - If there was no progress during the inflate() call, return a buffer - error. Call updatewindow() to create and/or update the window state. - Note: a memory error from inflate() is non-recoverable. - */ - inf_leave: - RESTORE(); - if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) - if (updatewindow(strm, out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - in -= strm->avail_in; - out -= strm->avail_out; - strm->total_in += in; - strm->total_out += out; - state->total += out; - if (state->wrap && out) - strm->adler = state->check = - UPDATE(state->check, strm->next_out - out, out); - strm->data_type = state->bits + (state->last ? 64 : 0) + - (state->mode == TYPE ? 128 : 0); - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) - ret = Z_BUF_ERROR; - return ret; -} - -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->window != Z_NULL) ZFREE(strm, state->window); - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ - struct inflate_state FAR *state; - unsigned long id; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->wrap != 0 && state->mode != DICT) - return Z_STREAM_ERROR; - - /* check for correct dictionary id */ - if (state->mode == DICT) { - id = adler32(0L, Z_NULL, 0); - id = adler32(id, dictionary, dictLength); - if (id != state->check) - return Z_DATA_ERROR; - } - - /* copy dictionary to window */ - if (updatewindow(strm, strm->avail_out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - if (dictLength > state->wsize) { - zmemcpy(state->window, dictionary + dictLength - state->wsize, - state->wsize); - state->whave = state->wsize; - } - else { - zmemcpy(state->window + state->wsize - dictLength, dictionary, - dictLength); - state->whave = dictLength; - } - state->havedict = 1; - Tracev((stderr, "inflate: dictionary set\n")); - return Z_OK; -} - -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ - struct inflate_state FAR *state; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; - - /* save header structure */ - state->head = head; - head->done = 0; - return Z_OK; -} - -/* - Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found - or when out of input. When called, *have is the number of pattern bytes - found in order so far, in 0..3. On return *have is updated to the new - state. If on return *have equals four, then the pattern was found and the - return value is how many bytes were read including the last byte of the - pattern. If *have is less than four, then the pattern has not been found - yet and the return value is len. In the latter case, syncsearch() can be - called again with more data and the *have state. *have is initialized to - zero for the first call. - */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -unsigned char FAR *buf; -unsigned len; -{ - unsigned got; - unsigned next; - - got = *have; - next = 0; - while (next < len && got < 4) { - if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) - got++; - else if (buf[next]) - got = 0; - else - got = 4 - got; - next++; - } - *have = got; - return next; -} - -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ - unsigned len; /* number of bytes to look at or looked at */ - unsigned long in, out; /* temporary to save total_in and total_out */ - unsigned char buf[4]; /* to restore bit buffer to byte string */ - struct inflate_state FAR *state; - - /* check parameters */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; - - /* if first time, start search in bit buffer */ - if (state->mode != SYNC) { - state->mode = SYNC; - state->hold <<= state->bits & 7; - state->bits -= state->bits & 7; - len = 0; - while (state->bits >= 8) { - buf[len++] = (unsigned char)(state->hold); - state->hold >>= 8; - state->bits -= 8; - } - state->have = 0; - syncsearch(&(state->have), buf, len); - } - - /* search available input */ - len = syncsearch(&(state->have), strm->next_in, strm->avail_in); - strm->avail_in -= len; - strm->next_in += len; - strm->total_in += len; - - /* return no joy or set up to restart inflate() on a new block */ - if (state->have != 4) return Z_DATA_ERROR; - in = strm->total_in; out = strm->total_out; - inflateReset(strm); - strm->total_in = in; strm->total_out = out; - state->mode = TYPE; - return Z_OK; -} - -/* - Returns true if inflate is currently at the end of a block generated by - Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - implementation to provide an additional safety check. PPP uses - Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored - block. When decompressing, PPP checks that at the end of input packet, - inflate is waiting for these length bytes. - */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - return state->mode == STORED && state->bits == 0; -} - -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ - struct inflate_state FAR *state; - struct inflate_state FAR *copy; - unsigned char FAR *window; - unsigned wsize; - - /* check input */ - if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || - source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)source->state; - - /* allocate space */ - copy = (struct inflate_state FAR *) - ZALLOC(source, 1, sizeof(struct inflate_state)); - if (copy == Z_NULL) return Z_MEM_ERROR; - window = Z_NULL; - if (state->window != Z_NULL) { - window = (unsigned char FAR *) - ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); - if (window == Z_NULL) { - ZFREE(source, copy); - return Z_MEM_ERROR; - } - } - - /* copy state */ - zmemcpy(dest, source, sizeof(z_stream)); - zmemcpy(copy, state, sizeof(struct inflate_state)); - if (state->lencode >= state->codes && - state->lencode <= state->codes + ENOUGH - 1) { - copy->lencode = copy->codes + (state->lencode - state->codes); - copy->distcode = copy->codes + (state->distcode - state->codes); - } - copy->next = copy->codes + (state->next - state->codes); - if (window != Z_NULL) { - wsize = 1U << state->wbits; - zmemcpy(window, state->window, wsize); - } - copy->window = window; - dest->state = (struct internal_state FAR *)copy; - return Z_OK; -} diff --git a/sourcepawn/jit/zlib/inflate.h b/sourcepawn/jit/zlib/inflate.h deleted file mode 100644 index fbbc8714..00000000 --- a/sourcepawn/jit/zlib/inflate.h +++ /dev/null @@ -1,115 +0,0 @@ -/* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip decoding - should be left enabled. */ -#ifndef NO_GZIP -# define GUNZIP -#endif - -/* Possible inflate modes between inflate() calls */ -typedef enum { - HEAD, /* i: waiting for magic header */ - FLAGS, /* i: waiting for method and flags (gzip) */ - TIME, /* i: waiting for modification time (gzip) */ - OS, /* i: waiting for extra flags and operating system (gzip) */ - EXLEN, /* i: waiting for extra length (gzip) */ - EXTRA, /* i: waiting for extra bytes (gzip) */ - NAME, /* i: waiting for end of file name (gzip) */ - COMMENT, /* i: waiting for end of comment (gzip) */ - HCRC, /* i: waiting for header crc (gzip) */ - DICTID, /* i: waiting for dictionary check value */ - DICT, /* waiting for inflateSetDictionary() call */ - TYPE, /* i: waiting for type bits, including last-flag bit */ - TYPEDO, /* i: same, but skip check to exit inflate on new block */ - STORED, /* i: waiting for stored size (length and complement) */ - COPY, /* i/o: waiting for input or output to copy stored block */ - TABLE, /* i: waiting for dynamic block table lengths */ - LENLENS, /* i: waiting for code length code lengths */ - CODELENS, /* i: waiting for length/lit and distance code lengths */ - LEN, /* i: waiting for length/lit code */ - LENEXT, /* i: waiting for length extra bits */ - DIST, /* i: waiting for distance code */ - DISTEXT, /* i: waiting for distance extra bits */ - MATCH, /* o: waiting for output space to copy string */ - LIT, /* o: waiting for output space to write literal */ - CHECK, /* i: waiting for 32-bit check value */ - LENGTH, /* i: waiting for 32-bit length (gzip) */ - DONE, /* finished check, done -- remain here until reset */ - BAD, /* got a data error -- remain here until reset */ - MEM, /* got an inflate() memory error -- remain here until reset */ - SYNC /* looking for synchronization bytes to restart inflate() */ -} inflate_mode; - -/* - State transitions between above modes - - - (most modes can go to the BAD or MEM mode -- not shown for clarity) - - Process header: - HEAD -> (gzip) or (zlib) - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME - NAME -> COMMENT -> HCRC -> TYPE - (zlib) -> DICTID or TYPE - DICTID -> DICT -> TYPE - Read deflate blocks: - TYPE -> STORED or TABLE or LEN or CHECK - STORED -> COPY -> TYPE - TABLE -> LENLENS -> CODELENS -> LEN - Read deflate codes: - LEN -> LENEXT or LIT or TYPE - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN - LIT -> LEN - Process trailer: - CHECK -> LENGTH -> DONE - */ - -/* state maintained between inflate() calls. Approximately 7K bytes. */ -struct inflate_state { - inflate_mode mode; /* current inflate mode */ - int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags (0 if zlib) */ - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - unsigned long check; /* protected copy of check value */ - unsigned long total; /* protected copy of output count */ - gz_headerp head; /* where to save gzip header information */ - /* sliding window */ - unsigned wbits; /* log base 2 of requested window size */ - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned write; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - /* bit accumulator */ - unsigned long hold; /* input bit accumulator */ - unsigned bits; /* number of bits in "in" */ - /* for string and stored block copying */ - unsigned length; /* literal or length of data to copy */ - unsigned offset; /* distance back to copy string from */ - /* for table and code decoding */ - unsigned extra; /* extra bits needed */ - /* fixed and dynamic code tables */ - code const FAR *lencode; /* starting table for length/literal codes */ - code const FAR *distcode; /* starting table for distance codes */ - unsigned lenbits; /* index bits for lencode */ - unsigned distbits; /* index bits for distcode */ - /* dynamic table building */ - unsigned ncode; /* number of code length code lengths */ - unsigned nlen; /* number of length code lengths */ - unsigned ndist; /* number of distance code lengths */ - unsigned have; /* number of code lengths in lens[] */ - code FAR *next; /* next available space in codes[] */ - unsigned short lens[320]; /* temporary storage for code lengths */ - unsigned short work[288]; /* work area for code table building */ - code codes[ENOUGH]; /* space for code tables */ -}; diff --git a/sourcepawn/jit/zlib/inftrees.c b/sourcepawn/jit/zlib/inftrees.c deleted file mode 100644 index a1406443..00000000 --- a/sourcepawn/jit/zlib/inftrees.c +++ /dev/null @@ -1,330 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include -#include "zutil.h" -#include "inftrees.h" - -#define MAXBITS 15 - -const char inflate_copyright[] = - " inflate 1.2.3 Copyright 1995-2005 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* - Build a set of tables to decode the provided canonical Huffman code. - The code lengths are lens[0..codes-1]. The result starts at *table, - whose indices are 0..2^bits-1. work is a writable array of at least - lens shorts, which is used as a work area. type is the type of code - to be generated, CODES, LENS, or DISTS. On return, zero is success, - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table - on return points to the next available entry's address. bits is the - requested root table index bits, and on return it is the actual root - table index bits. It will differ if the request is greater than the - longest code or if it is less than the shortest code. - */ -int inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ - unsigned len; /* a code's length in bits */ - unsigned sym; /* index of code symbols */ - unsigned min, max; /* minimum and maximum code lengths */ - unsigned root; /* number of index bits for root table */ - unsigned curr; /* number of index bits for current table */ - unsigned drop; /* code bits to drop for sub-table */ - int left; /* number of prefix codes available */ - unsigned used; /* code entries in table used */ - unsigned huff; /* Huffman code */ - unsigned incr; /* for incrementing code, index */ - unsigned fill; /* index for replicating entries */ - unsigned low; /* low bits for current root entry */ - unsigned mask; /* mask for low root bits */ - code this; /* table entry for duplication */ - code FAR *next; /* next available space in table */ - const unsigned short FAR *base; /* base value table to use */ - const unsigned short FAR *extra; /* extra bits table to use */ - int end; /* use base and extra for symbol > end */ - unsigned short count[MAXBITS+1]; /* number of codes of each length */ - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ - static const unsigned short lbase[31] = { /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - static const unsigned short lext[31] = { /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196}; - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0}; - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64}; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) - count[len] = 0; - for (sym = 0; sym < codes; sym++) - count[lens[sym]]++; - - /* bound code lengths, force root to be within code lengths */ - root = *bits; - for (max = MAXBITS; max >= 1; max--) - if (count[max] != 0) break; - if (root > max) root = max; - if (max == 0) { /* no symbols to code at all */ - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)1; - this.val = (unsigned short)0; - *(*table)++ = this; /* make a table to force an error */ - *(*table)++ = this; - *bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min <= MAXBITS; min++) - if (count[min] != 0) break; - if (root < min) root = min; - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) return -1; /* over-subscribed */ - } - if (left > 0 && (type == CODES || max != 1)) - return -1; /* incomplete set */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + count[len]; - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked when a LENS table is being made - against the space in *table, ENOUGH, minus the maximum space needed by - the worst case distance code, MAXD. This should never happen, but the - sufficiency of ENOUGH has not been proven exhaustively, hence the check. - This assumes that when type == LENS, bits == 9. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - switch (type) { - case CODES: - base = extra = work; /* dummy value--not used */ - end = 19; - break; - case LENS: - base = lbase; - base -= 257; - extra = lext; - extra -= 257; - end = 256; - break; - default: /* DISTS */ - base = dbase; - extra = dext; - end = -1; - } - - /* initialize state for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = *table; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = (unsigned)(-1); /* trigger new sub-table when len > root */ - used = 1U << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if (type == LENS && used >= ENOUGH - MAXD) - return 1; - - /* process all codes and make table entries */ - for (;;) { - /* create table entry */ - this.bits = (unsigned char)(len - drop); - if ((int)(work[sym]) < end) { - this.op = (unsigned char)0; - this.val = work[sym]; - } - else if ((int)(work[sym]) > end) { - this.op = (unsigned char)(extra[work[sym]]); - this.val = base[work[sym]]; - } - else { - this.op = (unsigned char)(32 + 64); /* end of block */ - this.val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1U << (len - drop); - fill = 1U << curr; - min = fill; /* save offset to next table */ - do { - fill -= incr; - next[(huff >> drop) + fill] = this; - } while (fill != 0); - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - - /* go to next symbol, update count, len */ - sym++; - if (--(count[len]) == 0) { - if (len == max) break; - len = lens[work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) != low) { - /* if first time, transition to sub-tables */ - if (drop == 0) - drop = root; - - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = (int)(1 << curr); - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) break; - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1U << curr; - if (type == LENS && used >= ENOUGH - MAXD) - return 1; - - /* point entry in root table to sub-table */ - low = huff & mask; - (*table)[low].op = (unsigned char)curr; - (*table)[low].bits = (unsigned char)root; - (*table)[low].val = (unsigned short)(next - *table); - } - } - - /* - Fill in rest of table for incomplete codes. This loop is similar to the - loop above in incrementing huff for table indices. It is assumed that - len is equal to curr + drop, so there is no loop needed to increment - through high index bits. When the current sub-table is filled, the loop - drops back to the root table to fill in any remaining entries there. - */ - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)(len - drop); - this.val = (unsigned short)0; - while (huff != 0) { - /* when done with sub-table, drop back to root table */ - if (drop != 0 && (huff & mask) != low) { - drop = 0; - len = root; - next = *table; - this.bits = (unsigned char)len; - } - - /* put invalid code marker in table */ - next[huff >> drop] = this; - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - } - - /* set return parameters */ - *table += used; - *bits = root; - return 0; -} diff --git a/sourcepawn/jit/zlib/inftrees.h b/sourcepawn/jit/zlib/inftrees.h deleted file mode 100644 index dc0fd567..00000000 --- a/sourcepawn/jit/zlib/inftrees.h +++ /dev/null @@ -1,55 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Structure for decoding tables. Each entry provides either the - information needed to do the operation requested by the code that - indexed that table entry, or it provides a pointer to another - table that indexes more bits of the code. op indicates whether - the entry is a pointer to another table, a literal, a length or - distance, an end-of-block, or an invalid code. For a table - pointer, the low four bits of op is the number of index bits of - that table. For a length or distance, the low four bits of op - is the number of extra bits to get after the code. bits is - the number of bits in this code or part of the code to drop off - of the bit buffer. val is the actual byte to output in the case - of a literal, the base length or distance, or the offset from - the current table to the next table. Each entry is four bytes. */ -typedef struct { - unsigned char op; /* operation, extra bits, table bits */ - unsigned char bits; /* bits in this part of the code */ - unsigned short val; /* offset in table or code value */ -} code; - -/* op values as set by inflate_table(): - 00000000 - literal - 0000tttt - table link, tttt != 0 is the number of table index bits - 0001eeee - length or distance, eeee is the number of extra bits - 01100000 - end of block - 01000000 - invalid code - */ - -/* Maximum size of dynamic tree. The maximum found in a long but non- - exhaustive search was 1444 code structures (852 for length/literals - and 592 for distances, the latter actually the result of an - exhaustive search). The true maximum is not known, but the value - below is more than safe. */ -#define ENOUGH 2048 -#define MAXD 592 - -/* Type of code to build for inftable() */ -typedef enum { - CODES, - LENS, - DISTS -} codetype; - -extern int inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); diff --git a/sourcepawn/jit/zlib/trees.c b/sourcepawn/jit/zlib/trees.c deleted file mode 100644 index 6ca02864..00000000 --- a/sourcepawn/jit/zlib/trees.c +++ /dev/null @@ -1,1220 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2005 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in a compressed form which is itself - * a Huffman encoding of the lengths of all the code strings (in - * ascending order by source values). The actual code strings are - * reconstructed from the lengths in the inflate process, as described - * in the deflate specification. - * - * REFERENCES - * - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - */ - -/* @(#) $Id$ */ - -/* #define GEN_TREES_H */ - -#include -#include "deflate.h" - -#ifdef DEBUG -# include -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local const int extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -local const uch bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -#define Buf_size (8 * 2*sizeof(char)) -/* Number of bits used within bi_buf. (bi_buf might be implemented on - * more than 16 bits on some systems.) - */ - -/* =========================================================================== - * Local data. These are initialized only once. - */ - -#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ - -#if defined(GEN_TREES_H) || !defined(STDC) -/* non ANSI compilers may not accept trees.h */ - -local ct_data static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init - * below). - */ - -local ct_data static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -uch _dist_code[DIST_CODE_LEN]; -/* Distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -uch _length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local int base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -#else -# include "trees.h" -#endif /* GEN_TREES_H */ - -struct static_tree_desc_s { - const ct_data *static_tree; /* static tree or NULL */ - const intf *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ -}; - -local static_tree_desc static_l_desc = -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; - -local static_tree_desc static_d_desc = -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; - -local static_tree_desc static_bl_desc = -{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, ct_data *ltree, - ct_data *dtree)); -local void set_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned value, int length)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); -local void copy_block OF((deflate_state *s, charf *buf, unsigned len, - int header)); - -#ifdef GEN_TREES_H -local void gen_trees_header OF((void)); -#endif - -#ifndef DEBUG -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* DEBUG */ -# define send_code(s, c, tree) \ - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(s, tree[c].Code, tree[c].Len); } -#endif - -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -#ifdef DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - Tracevv((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; - - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (s->bi_valid > (int)Buf_size - length) { - s->bi_buf |= (value << s->bi_valid); - put_short(s, s->bi_buf); - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); - s->bi_valid += length - Buf_size; - } else { - s->bi_buf |= value << s->bi_valid; - s->bi_valid += length; - } -} -#else /* !DEBUG */ - -#define send_bits(s, value, length) \ -{ int len = length;\ - if (s->bi_valid > (int)Buf_size - len) {\ - int val = value;\ - s->bi_buf |= (val << s->bi_valid);\ - put_short(s, s->bi_buf);\ - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ - s->bi_valid += len - Buf_size;\ - } else {\ - s->bi_buf |= (value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* DEBUG */ - - -/* the arguments must not have side effects */ - -/* =========================================================================== - * Initialize the various 'constant' tables. - */ -local void tr_static_init() -{ -#if defined(GEN_TREES_H) || !defined(STDC) - static int static_init_done = 0; - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - if (static_init_done) return; - - /* For some embedded targets, global variables are not initialized: */ - static_l_desc.static_tree = static_ltree; - static_l_desc.extra_bits = extra_lbits; - static_d_desc.static_tree = static_dtree; - static_d_desc.extra_bits = extra_dbits; - static_bl_desc.extra_bits = extra_blbits; - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - _dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse((unsigned)n, 5); - } - static_init_done = 1; - -# ifdef GEN_TREES_H - gen_trees_header(); -# endif -#endif /* defined(GEN_TREES_H) || !defined(STDC) */ -} - -/* =========================================================================== - * Genererate the file trees.h describing the static trees. - */ -#ifdef GEN_TREES_H -# ifndef DEBUG -# include -# endif - -# define SEPARATOR(i, last, width) \ - ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) - -void gen_trees_header() -{ - FILE *header = fopen("trees.h", "w"); - int i; - - Assert (header != NULL, "Can't open trees.h"); - fprintf(header, - "/* header created automatically with -DGEN_TREES_H */\n\n"); - - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); - for (i = 0; i < L_CODES+2; i++) { - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); - } - - fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); - } - - fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); - for (i = 0; i < DIST_CODE_LEN; i++) { - fprintf(header, "%2u%s", _dist_code[i], - SEPARATOR(i, DIST_CODE_LEN-1, 20)); - } - - fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - fprintf(header, "%2u%s", _length_code[i], - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); - } - - fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); - for (i = 0; i < LENGTH_CODES; i++) { - fprintf(header, "%1u%s", base_length[i], - SEPARATOR(i, LENGTH_CODES-1, 20)); - } - - fprintf(header, "local const int base_dist[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "%5u%s", base_dist[i], - SEPARATOR(i, D_CODES-1, 10)); - } - - fclose(header); -} -#endif /* GEN_TREES_H */ - -/* =========================================================================== - * Initialize the tree data structures for a new zlib stream. - */ -void _tr_init(s) - deflate_state *s; -{ - tr_static_init(); - - s->l_desc.dyn_tree = s->dyn_ltree; - s->l_desc.stat_desc = &static_l_desc; - - s->d_desc.dyn_tree = s->dyn_dtree; - s->d_desc.stat_desc = &static_d_desc; - - s->bl_desc.dyn_tree = s->bl_tree; - s->bl_desc.stat_desc = &static_bl_desc; - - s->bi_buf = 0; - s->bi_valid = 0; - s->last_eob_len = 8; /* enough lookahead for inflate */ -#ifdef DEBUG - s->compressed_len = 0L; - s->bits_sent = 0L; -#endif - - /* Initialize the first block of the first file: */ - init_block(s); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->last_lit = s->matches = 0; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(s, tree, top) \ -{\ - top = s->heap[SMALLEST]; \ - s->heap[SMALLEST] = s->heap[s->heap_len--]; \ - pqdownheap(s, tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m, depth) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = s->heap[k]; - int j = k << 1; /* left son of k */ - while (j <= s->heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < s->heap_len && - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { - j++; - } - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, s->heap[j], s->depth)) break; - - /* Exchange v with the smallest son */ - s->heap[k] = s->heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - s->heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - ct_data *tree = desc->dyn_tree; - int max_code = desc->max_code; - const ct_data *stree = desc->stat_desc->static_tree; - const intf *extra = desc->stat_desc->extra_bits; - int base = desc->stat_desc->extra_base; - int max_length = desc->stat_desc->max_length; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - - for (h = s->heap_max+1; h < HEAP_SIZE; h++) { - n = s->heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - s->bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - s->opt_len += (ulg)f * (bits + xbits); - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); - } - if (overflow == 0) return; - - Trace((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ - s->bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = s->bl_count[bits]; - while (n != 0) { - m = s->heap[--h]; - if (m > max_code) continue; - if ((unsigned) tree[m].Len != (unsigned) bits) { - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s->opt_len += ((long)bits - (long)tree[m].Len) - *(long)tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; - const ct_data *stree = desc->stat_desc->static_tree; - int elems = desc->stat_desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node; /* new node being created */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - s->heap_len = 0, s->heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - s->heap[++(s->heap_len)] = max_code = n; - s->depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (s->heap_len < 2) { - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); - tree[node].Freq = 1; - s->depth[node] = 0; - s->opt_len--; if (stree) s->static_len -= stree[node].Len; - /* node is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - node = elems; /* next internal node of the tree */ - do { - pqremove(s, tree, n); /* n = node of least frequency */ - m = s->heap[SMALLEST]; /* m = node of next least frequency */ - - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ - s->heap[--(s->heap_max)] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? - s->depth[n] : s->depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == s->bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - s->heap[SMALLEST] = node++; - pqdownheap(s, tree, SMALLEST); - - } while (s->heap_len >= 2); - - s->heap[--(s->heap_max)] = s->heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen(s, (tree_desc *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data *)tree, max_code, s->bl_count); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. - */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - s->bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) s->bl_tree[curlen].Freq++; - s->bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - s->bl_tree[REPZ_3_10].Freq++; - } else { - s->bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(s, curlen, s->bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(s, curlen, s->bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); - - } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); - - } else { - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree(s) - deflate_state *s; -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); - - /* Build the bit length tree: */ - build_tree(s, (tree_desc *)(&(s->bl_desc))); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*(max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", - s->opt_len, s->static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); -} - -/* =========================================================================== - * Send a stored block - */ -void _tr_stored_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ -#ifdef DEBUG - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; - s->compressed_len += (stored_len + 4) << 3; -#endif - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ -} - -/* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - * The current inflate code requires 9 bits of lookahead. If the - * last two codes for the previous block (real code plus EOB) were coded - * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode - * the last real code. In this case we send two empty static blocks instead - * of one. (There are no problems if the previous block is stored or fixed.) - * To simplify the code, we assume the worst case of last real code encoded - * on one bit only. - */ -void _tr_align(s) - deflate_state *s; -{ - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ -#endif - bi_flush(s); - /* Of the 10 bits for the empty block, we have already sent - * (10 - bi_valid) bits. The lookahead for the last real code (before - * the EOB of the previous block) was thus at least one plus the length - * of the EOB plus what we have just sent of the empty static block. - */ - if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; -#endif - bi_flush(s); - } - s->last_eob_len = 7; -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. - */ -void _tr_flush_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex = 0; /* index of last bit length code of non zero freq */ - - /* Build the Huffman trees unless a stored block is forced */ - if (s->level > 0) { - - /* Check if the file is binary or text */ - if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN) - set_data_type(s); - - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); - - /* Determine the best encoding. Compute the block lengths in bytes. */ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; - - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - } else { - Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ - } - -#ifdef FORCE_STORED - if (buf != (char*)0) { /* force stored block */ -#else - if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - _tr_stored_block(s, buf, stored_len, eof); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+eof, 3); - compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->static_len; -#endif - } else { - send_bits(s, (DYN_TREES<<1)+eof, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); - compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->opt_len; -#endif - } - Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - /* The above check is made mod 2^32, for files larger than 512 MB - * and uLong implemented on 32 bits. - */ - init_block(s); - - if (eof) { - bi_windup(s); -#ifdef DEBUG - s->compressed_len += 7; /* align on byte boundary */ -#endif - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - s->compressed_len-7*eof)); -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - s->d_buf[s->last_lit] = (ush)dist; - s->l_buf[s->last_lit++] = (uch)lc; - if (dist == 0) { - /* lc is the unmatched char */ - s->dyn_ltree[lc].Freq++; - } else { - s->matches++; - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST(s) && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; - s->dyn_dtree[d_code(dist)].Freq++; - } - -#ifdef TRUNCATE_BLOCK - /* Try to guess if it is profitable to stop the current block here */ - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)s->last_lit*8L; - ulg in_length = (ulg)((long)s->strstart - s->block_start); - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * - (5L+extra_dbits[dcode]); - } - out_length >>= 3; - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - s->last_lit, in_length, out_length, - 100L - out_length*100L/in_length)); - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; - } -#endif - return (s->last_lit == s->lit_bufsize-1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - ct_data *ltree; /* literal tree */ - ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->last_lit != 0) do { - dist = s->d_buf[lx]; - lc = s->l_buf[lx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, - "pendingBuf overflow"); - - } while (lx < s->last_lit); - - send_code(s, END_BLOCK, ltree); - s->last_eob_len = ltree[END_BLOCK].Len; -} - -/* =========================================================================== - * Set the data type to BINARY or TEXT, using a crude approximation: - * set it to Z_TEXT if all symbols are either printable characters (33 to 255) - * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise. - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local void set_data_type(s) - deflate_state *s; -{ - int n; - - for (n = 0; n < 9; n++) - if (s->dyn_ltree[n].Freq != 0) - break; - if (n == 9) - for (n = 14; n < 32; n++) - if (s->dyn_ltree[n].Freq != 0) - break; - s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef DEBUG - s->bits_sent = (s->bits_sent+7) & ~7; -#endif -} - -/* =========================================================================== - * Copy a stored block, storing first the length and its - * one's complement if requested. - */ -local void copy_block(s, buf, len, header) - deflate_state *s; - charf *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(s); /* align on byte boundary */ - s->last_eob_len = 8; /* enough lookahead for inflate */ - - if (header) { - put_short(s, (ush)len); - put_short(s, (ush)~len); -#ifdef DEBUG - s->bits_sent += 2*16; -#endif - } -#ifdef DEBUG - s->bits_sent += (ulg)len<<3; -#endif - while (len--) { - put_byte(s, *buf++); - } -} diff --git a/sourcepawn/jit/zlib/trees.h b/sourcepawn/jit/zlib/trees.h deleted file mode 100644 index 1ca868b8..00000000 --- a/sourcepawn/jit/zlib/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_TREES_H */ - -local const ct_data static_ltree[L_CODES+2] = { -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} -}; - -local const ct_data static_dtree[D_CODES] = { -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} -}; - -const uch _dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -local const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -local const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - diff --git a/sourcepawn/jit/zlib/uncompr.c b/sourcepawn/jit/zlib/uncompr.c deleted file mode 100644 index ad6db0a6..00000000 --- a/sourcepawn/jit/zlib/uncompr.c +++ /dev/null @@ -1,61 +0,0 @@ -/* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-2003 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. -*/ -int ZEXPORT uncompress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - z_stream stream; - int err; - - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - err = inflateInit(&stream); - if (err != Z_OK) return err; - - err = inflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - inflateEnd(&stream); - if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) - return Z_DATA_ERROR; - return err; - } - *destLen = stream.total_out; - - err = inflateEnd(&stream); - return err; -} diff --git a/sourcepawn/jit/zlib/zconf.h b/sourcepawn/jit/zlib/zconf.h deleted file mode 100644 index 59b5e7a6..00000000 --- a/sourcepawn/jit/zlib/zconf.h +++ /dev/null @@ -1,281 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ -# include /* for off_t */ -# include /* for SEEK_* and off_t */ -# ifdef VMS -# include /* for off_t */ -# endif -# define z_off_t off_t -#endif -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif -#ifndef z_off_t -# define z_off_t long -#endif - -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -# ifdef FAR -# undef FAR -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) -# pragma map(deflateInit_,"DEIN") -# pragma map(deflateInit2_,"DEIN2") -# pragma map(deflateEnd,"DEEND") -# pragma map(deflateBound,"DEBND") -# pragma map(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(compressBound,"CMBND") -# pragma map(inflate_table,"INTABL") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/sourcepawn/jit/zlib/zlib.h b/sourcepawn/jit/zlib/zlib.h deleted file mode 100644 index 62d0e467..00000000 --- a/sourcepawn/jit/zlib/zlib.h +++ /dev/null @@ -1,1357 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.3, July 18th, 2005 - - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.3" -#define ZLIB_VERNUM 0x1230 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms will be added later and will have the same - stream interface. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never - crash even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce some - output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumualte before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In particular - avail_in is zero after the call if enough output space has been provided - before the call.) Flushing may degrade compression for some compression - algorithms and so it should be used only when necessary. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - the value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact - value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, - Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() stop - if and when it gets to the next deflate block boundary. When decoding the - zlib or gzip format, this will cause inflate() to return immediately after - the header and before the first block. When doing a raw inflate, inflate() - will go ahead and process the first block, and will return when it gets to - the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 - if inflate() is currently decoding the last block in the deflate stream, - plus 128 if inflate() returned immediately after decoding an end-of-block - code or decoding the complete header up to just before the first byte of the - deflate stream. The end-of-block will not be indicated until all of the - uncompressed data from that block has been written to strm->next_out. The - number of unused bits may in general be greater than seven, except when - bit 7 of data_type is set, in which case the number of unused bits will be - less than eight. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster approach - may be used for the single inflate() call. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the adler32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() will decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically. Any information - contained in the gzip header is not retained, so applications that need that - information should instead use raw inflate, see inflateInit2() below, or - inflateBack() and perform their own processing of the gzip header and - trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may then - call inflateSync() to look for a good compression block if a partial recovery - of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), - no header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as - Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy - parameter only affects the compression ratio but not the correctness of the - compressed output even if it is not set appropriately. Z_FIXED prevents the - use of dynamic Huffman codes, allowing for a simpler decoder for special - applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. In addition, the - current implementation of deflate will use at most the window size minus - 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different - strategy. If the compression level is changed, the input available so far - is compressed with the old level (and may be flushed); the new level will - take effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() - or deflateInit2(). This would be used to allocate an output buffer - for deflation in a single pass, and so would be called before deflate(). -*/ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the - bits leftover from a previous deflate stream when appending to it. As such, - this function can only be used for raw deflate, and must be used before the - first deflate() call after a deflateInit2() or deflateReset(). bits must be - less than or equal to 16, and that many of the least significant bits of - value will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is - a crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg - is set to null if there is no error message. inflateInit2 does not perform - any decompression apart from reading the zlib header if present: this will - be done by inflate(). (So next_in and avail_in may be modified, but next_out - and avail_out are unchanged.) -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been found, - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current current value of total_in which - indicates where valid compressed data was found. In the error case, the - application may repeatedly call inflateSync, providing more input each time, - until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. - The stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK can be used to - force inflate() to return immediately after header processing is complete - and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When - any of extra, name, or comment are not Z_NULL and the respective field is - not present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not - be allocated, or Z_VERSION_ERROR if the version of the library does not - match the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free - the allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects - only the raw deflate stream to decompress. This is different from the - normal behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format - error in the deflate stream (in which case strm->msg is set to indicate the - nature of the error), or Z_STREAM_ERROR if the stream was not properly - initialized. In the case of Z_BUF_ERROR, an input or output error can be - distinguished using strm->next_in which will be Z_NULL only if in() returned - an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to - out() returning non-zero. (in() will always be called before out(), so - strm->next_in is assured to be defined if out() returns non-zero.) Note - that inflateBack() cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the - basic stream-oriented functions. To simplify the interface, some - default options are assumed (compression level and memory usage, - standard memory allocation functions). The source code of these - utility functions can easily be modified if you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be at least the value returned - by compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before - a compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. -*/ - - -typedef voidp gzFile; - -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); -/* - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb") but can also include a compression level - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for - Huffman only compression as in "wb1h", or 'R' for run-length encoding - as in "wb1R". (See the description of deflateInit2 for more information - about the strategy parameter.) - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen() associates a gzFile with the file descriptor fd. File - descriptors are obtained from calls like open, dup, creat, pipe or - fileno (in the file has been previously opened with fopen). - The mode parameter is as in gzopen. - The next call of gzclose on the returned gzFile will also close the - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). The number of - uncompressed bytes written is limited to 4095. The caller should assure that - this limit is not exceeded. If it is exceeded, then gzprintf() will return - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() - because the secure snprintf() or vsnprintf() functions were not available. -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or - a newline character is read and transferred to buf, or an end-of-file - condition is encountered. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read again later. - Only one character of push-back is allowed. gzungetc() returns the - character pushed, or -1 on failure. gzungetc() will fail if a - character has been pushed but not read yet, or if c is -1. The pushed - character will be discarded if the stream is repositioned with gzseek() - or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. The return value is the zlib - error number (see function gzerror below). gzflush returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); -/* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); -/* - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns 1 if file is being read directly without decompression, otherwise - zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); -/* - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is NULL, this function returns the required initial - value for the for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - -/* - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - - -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/sourcepawn/jit/zlib/zutil.c b/sourcepawn/jit/zlib/zutil.c deleted file mode 100644 index 56e552f4..00000000 --- a/sourcepawn/jit/zlib/zutil.c +++ /dev/null @@ -1,319 +0,0 @@ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include -#include "zutil.h" - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -const char * const z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; - - -const char * ZEXPORT zlibVersion() -{ - return ZLIB_VERSION; -} - -uLong ZEXPORT zlibCompileFlags() -{ - uLong flags; - - flags = 0; - switch (sizeof(uInt)) { - case 2: break; - case 4: flags += 1; break; - case 8: flags += 2; break; - default: flags += 3; - } - switch (sizeof(uLong)) { - case 2: break; - case 4: flags += 1 << 2; break; - case 8: flags += 2 << 2; break; - default: flags += 3 << 2; - } - switch (sizeof(voidpf)) { - case 2: break; - case 4: flags += 1 << 4; break; - case 8: flags += 2 << 4; break; - default: flags += 3 << 4; - } - switch (sizeof(z_off_t)) { - case 2: break; - case 4: flags += 1 << 6; break; - case 8: flags += 2 << 6; break; - default: flags += 3 << 6; - } -#ifdef DEBUG - flags += 1 << 8; -#endif -#if defined(ASMV) || defined(ASMINF) - flags += 1 << 9; -#endif -#ifdef ZLIB_WINAPI - flags += 1 << 10; -#endif -#ifdef BUILDFIXED - flags += 1 << 12; -#endif -#ifdef DYNAMIC_CRC_TABLE - flags += 1 << 13; -#endif -#ifdef NO_GZCOMPRESS - flags += 1L << 16; -#endif -#ifdef NO_GZIP - flags += 1L << 17; -#endif -#ifdef PKZIP_BUG_WORKAROUND - flags += 1L << 20; -#endif -#ifdef FASTEST - flags += 1L << 21; -#endif -#ifdef STDC -# ifdef NO_vsnprintf - flags += 1L << 25; -# ifdef HAS_vsprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_vsnprintf_void - flags += 1L << 26; -# endif -# endif -#else - flags += 1L << 24; -# ifdef NO_snprintf - flags += 1L << 25; -# ifdef HAS_sprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_snprintf_void - flags += 1L << 26; -# endif -# endif -#endif - return flags; -} - -#ifdef DEBUG - -# ifndef verbose -# define verbose 0 -# endif -int z_verbose = verbose; - -void z_error (m) - char *m; -{ - fprintf(stderr, "%s\n", m); - exit(1); -} -#endif - -/* exported to allow conversion of error code to string for compress() and - * uncompress() - */ -const char * ZEXPORT zError(err) - int err; -{ - return ERR_MSG(err); -} - -#if defined(_WIN32_WCE) - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. - */ - int errno = 0; -#endif - -#ifndef HAVE_MEMCPY - -void zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); -} - -int zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ - uInt j; - - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; -} - -void zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - - -#ifdef SYS16BIT - -#ifdef __TURBOC__ -/* Turbo C in 16-bit mode */ - -# define MY_ZCALLOC - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use zcfree(). - */ - -#define MAX_PTR 10 -/* 10*64K = 640K */ - -local int next_ptr = 0; - -typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; -} ptr_table; - -local ptr_table table[MAX_PTR]; -/* This table is used to remember the original form of pointers - * to large buffers (64K). Such pointers are normalized with a zero offset. - * Since MSDOS is not a preemptive multitasking OS, this table is not - * protected from concurrent access. This hack doesn't work anyway on - * a protected system like OS/2. Use Microsoft C instead. - */ - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - voidpf buf = opaque; /* just to make some compilers happy */ - ulg bsize = (ulg)items*size; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - int n; - if (*(ush*)&ptr != 0) { /* object < 64K */ - farfree(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - farfree(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - ptr = opaque; /* just to make some compilers happy */ - Assert(0, "zcfree: ptr not found"); -} - -#endif /* __TURBOC__ */ - - -#ifdef M_I86 -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - return _halloc((long)items, size); -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - _hfree(ptr); -} - -#endif /* M_I86 */ - -#endif /* SYS16BIT */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - if (opaque) items += size - size; /* make compiler happy */ - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : - (voidpf)calloc(items, size); -} - -void zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - free(ptr); - if (opaque) return; /* make compiler happy */ -} - -#endif /* MY_ZCALLOC */ diff --git a/sourcepawn/jit/zlib/zutil.h b/sourcepawn/jit/zlib/zutil.h deleted file mode 100644 index 0ba6e020..00000000 --- a/sourcepawn/jit/zlib/zutil.h +++ /dev/null @@ -1,269 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#define ZLIB_INTERNAL -#include "zlib.h" - -#ifdef STDC -# ifndef _WIN32_WCE -# include -# endif -# include -# include -#endif -#ifdef NO_ERRNO_H -# ifdef _WIN32_WCE - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. We rename it to - * avoid conflict with other libraries that use the same workaround. - */ -# define errno z_errno -# endif - extern int errno; -#else -# ifndef _WIN32_WCE -# include -# endif -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -# ifdef M_I86 - #include -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# define vsnprintf _vsnprintf -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -#endif -#ifdef VMS -# define NO_vsnprintf -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int z_verbose; - extern void z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* ZUTIL_H */ diff --git a/sourcepawn/batchtool/compile.cfg b/tools/batchtool/compile.cfg similarity index 100% rename from sourcepawn/batchtool/compile.cfg rename to tools/batchtool/compile.cfg diff --git a/sourcepawn/batchtool/compile.dpr b/tools/batchtool/compile.dpr similarity index 100% rename from sourcepawn/batchtool/compile.dpr rename to tools/batchtool/compile.dpr diff --git a/sourcepawn/batchtool/compile.exe b/tools/batchtool/compile.exe similarity index 100% rename from sourcepawn/batchtool/compile.exe rename to tools/batchtool/compile.exe diff --git a/sourcepawn/batchtool/icon.rc b/tools/batchtool/icon.rc similarity index 100% rename from sourcepawn/batchtool/icon.rc rename to tools/batchtool/icon.rc diff --git a/sourcepawn/batchtool/icon.res b/tools/batchtool/icon.res similarity index 100% rename from sourcepawn/batchtool/icon.res rename to tools/batchtool/icon.res diff --git a/sourcepawn/batchtool/pawn.ico b/tools/batchtool/pawn.ico similarity index 100% rename from sourcepawn/batchtool/pawn.ico rename to tools/batchtool/pawn.ico diff --git a/sourcepawn/batchtool/uFunc.pas b/tools/batchtool/uFunc.pas similarity index 100% rename from sourcepawn/batchtool/uFunc.pas rename to tools/batchtool/uFunc.pas diff --git a/sourcepawn/batchtool/version.rc b/tools/batchtool/version.rc similarity index 100% rename from sourcepawn/batchtool/version.rc rename to tools/batchtool/version.rc diff --git a/sourcepawn/batchtool/version.res b/tools/batchtool/version.res similarity index 100% rename from sourcepawn/batchtool/version.res rename to tools/batchtool/version.res diff --git a/tools/buildbot/PackageScript b/tools/buildbot/PackageScript index 070bc903..9f158898 100644 --- a/tools/buildbot/PackageScript +++ b/tools/buildbot/PackageScript @@ -150,6 +150,7 @@ CopyFiles('gamedata/sdkhooks.games', 'addons/sourcemod/gamedata/sdkhooks.games', 'game.ag2.txt', 'game.alienswarm.txt', 'game.aoc.txt', + 'game.bms.txt', 'game.cspromod.txt', 'game.cstrike.txt', 'game.dinodday.txt', @@ -195,6 +196,7 @@ CopyFiles('gamedata/sdktools.games', 'addons/sourcemod/gamedata/sdktools.games', 'game.alienswarm.txt', 'game.aoc.txt', 'game.bg2.txt', + 'game.bms.txt', 'game.cspromod.txt', 'game.cstrike.txt', 'game.dinodday.txt', @@ -232,6 +234,7 @@ CopyFiles('gamedata/core.games', 'addons/sourcemod/gamedata/core.games', 'common.games.txt', 'engine.bgt.txt', 'engine.blade.txt', + 'engine.bms.txt', 'engine.contagion.txt', 'engine.csgo.txt', 'engine.css.txt', @@ -465,6 +468,6 @@ CopyFiles('plugins/playercommands', 'addons/sourcemod/scripting/playercommands', ) if builder.target_platform == 'windows': - CopyFiles('sourcepawn/batchtool', 'addons/sourcemod/scripting', ['compile.exe']) + CopyFiles('tools/batchtool', 'addons/sourcemod/scripting', ['compile.exe']) else: CopyFiles('plugins', 'addons/sourcemod/scripting', ['compile.sh']) diff --git a/tools/buildbot/bootstrap.pl b/tools/buildbot/bootstrap.pl index ce1c1152..d6514a0c 100755 --- a/tools/buildbot/bootstrap.pl +++ b/tools/buildbot/bootstrap.pl @@ -11,8 +11,14 @@ chdir($path); require 'helpers.pm'; +#Go back to tree root. +my ($result); +chdir(Build::PathFormat('../..')); +$result = `git submodule update --init --recursive`; +print "$result\n"; + #Go back above build dir -chdir(Build::PathFormat('../../..')); +chdir(Build::PathFormat('..')); #Get the source path. our ($root) = getcwd(); @@ -24,7 +30,7 @@ if (!(-f 'OUTPUT/.ambuild2/graph') || !(-f 'OUTPUT/.ambuild2/vars')) { mkdir('OUTPUT') or die("Failed to create output folder: $!\n"); } chdir('OUTPUT'); -my ($result, $argn); +my ($argn); $argn = $#ARGV + 1; print "Attempting to reconfigure...\n"; diff --git a/tools/checkout-deps.sh b/tools/checkout-deps.sh index 40461e0c..c0c9e5bb 100755 --- a/tools/checkout-deps.sh +++ b/tools/checkout-deps.sh @@ -79,7 +79,7 @@ sdks=( csgo hl2dm nucleardawn l4d2 dods l4d css tf2 insurgency sdk2013 dota ) if [ $ismac -eq 0 ]; then # Add these SDKs for Windows or Linux - sdks+=( orangebox blade episode1 ) + sdks+=( orangebox blade episode1 bms ) # Add more SDKs for Windows only if [ $iswin -eq 1 ]; then diff --git a/tools/gdc-psyfork/MemoryUtils.cpp b/tools/gdc-psyfork/MemoryUtils.cpp index 2aa73183..f11caa04 100644 --- a/tools/gdc-psyfork/MemoryUtils.cpp +++ b/tools/gdc-psyfork/MemoryUtils.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #define PAGE_SIZE 4096 #define PAGE_ALIGN_UP(x) ((x + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) diff --git a/tools/gdc-psyfork/symbols.txt b/tools/gdc-psyfork/symbols.txt index 14eb407a..69faffc0 100644 --- a/tools/gdc-psyfork/symbols.txt +++ b/tools/gdc-psyfork/symbols.txt @@ -1,352 +1,380 @@ -"Games" -{ - /* - * "Keys" are used to map gamedata offset names to linux symbol. - * "Options" are used to mark validation options for windows signatures. - * Current valid options are: - * allowmultiple - don't warn if multiple matches are found - * allowmidfunc - don't warn if signature does not match the - * start of a function. - * Multiple options can be specified, separating them with a comma. - * ie. "allowmultiple,allowmidfunc" - */ - - "#default" - { - "Keys" - { - // SDKTools - "GiveNamedItem" "_ZN11CBasePlayer13GiveNamedItemEPKci" - "RemovePlayerItem" "_ZN11CBasePlayer16RemovePlayerItemEP17CBaseCombatWeapon" - "Weapon_GetSlot" "_ZNK20CBaseCombatCharacter14Weapon_GetSlotEi" - "Ignite" "_ZN14CBaseAnimating6IgniteEfbfb" - "Extinguish" "_ZN14CBaseAnimating10ExtinguishEv" - "Teleport" "_ZN11CBaseEntity8TeleportEPK6VectorPK6QAngleS2_" - "CommitSuicide" "_ZN11CBasePlayer13CommitSuicideEbb" - "GetVelocity" "_ZN11CBaseEntity11GetVelocityEP6VectorS1_" - "EyeAngles" "_ZN11CBasePlayer9EyeAnglesEv" - "DispatchKeyValue" "_ZN11CBaseEntity8KeyValueEPKcS1_" - "DispatchKeyValueFloat" "_ZN11CBaseEntity8KeyValueEPKcf" - "DispatchKeyValueVector" "_ZN11CBaseEntity8KeyValueEPKcRK6Vector" - "SetEntityModel" "_ZN11CBaseEntity8SetModelEPKc" - "AcceptInput" "_ZN11CBaseEntity11AcceptInputEPKcPS_S2_9variant_ti" - "WeaponEquip" "_ZN11CBasePlayer12Weapon_EquipEP17CBaseCombatWeapon" - "Activate" "_ZN11CBaseEntity8ActivateEv" - "PlayerRunCmd" "_ZN11CBasePlayer16PlayerRunCommandEP8CUserCmdP11IMoveHelper" - - // SDKHooks - "EndTouch" "_ZN11CBaseEntity8EndTouchEPS_" - "FireBullets" "_ZN11CBaseEntity11FireBulletsERK17FireBulletsInfo_t" - "GroundEntChanged" "_ZN11CBaseEntity35NetworkStateChanged_m_hGroundEntityEPv" - "OnTakeDamage" "_ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo" - "PreThink" "_ZN11CBasePlayer8PreThinkEv" - "PostConstructor" "_ZN11CBaseEntity15PostConstructorEPKc" - "PostThink" "_ZN11CBasePlayer9PostThinkEv" - "Reload" "_ZN17CBaseCombatWeapon6ReloadEv" - "SetTransmit" "_ZN11CBaseEntity11SetTransmitEP18CCheckTransmitInfob" - "ShouldCollide" "_ZNK11CBaseEntity13ShouldCollideEii" - "Spawn" "_ZN11CBaseEntity5SpawnEv" - "StartTouch" "_ZN11CBaseEntity10StartTouchEPS_" - "Think" "_ZN11CBaseEntity5ThinkEv" - "Touch" "_ZN11CBaseEntity5TouchEPS_" - "TraceAttack" "_ZN11CBaseEntity11TraceAttackERK15CTakeDamageInfoRK6VectorP10CGameTrace" - "UpdateOnRemove" "_ZN11CBaseEntity14UpdateOnRemoveEv" - "Use" "_ZN11CBaseEntity3UseEPS_S0_8USE_TYPEf" - "VPhysicsUpdate" "_ZN11CBaseEntity14VPhysicsUpdateEP14IPhysicsObject" - "Weapon_CanSwitchTo" "_ZN20CBaseCombatCharacter18Weapon_CanSwitchToEP17CBaseCombatWeapon" - "Weapon_CanUse" "_ZN20CBaseCombatCharacter13Weapon_CanUseEP17CBaseCombatWeapon" - "Weapon_Drop" "_ZN20CBaseCombatCharacter11Weapon_DropEP17CBaseCombatWeaponPK6VectorS4_" - "Weapon_Equip" "_ZN11CBasePlayer12Weapon_EquipEP17CBaseCombatWeapon" - "Weapon_Switch" "_ZN20CBaseCombatCharacter13Weapon_SwitchEP17CBaseCombatWeaponi" - - // CEntity extras - "FVisible" "_ZN20CBaseCombatCharacter8FVisibleEP11CBaseEntityiPS1_" - "VPhysicsTakeDamage" "_ZN11CBaseEntity18VPhysicsTakeDamageERK15CTakeDamageInfo" - "VPhysicsGetObjectList" "_ZN11CBaseEntity21VPhysicsGetObjectListEPP14IPhysicsObjecti" - "GetClientEyeAngles" "_ZN11CBaseEntity9EyeAnglesEv" - "WeaponSwitch" "_ZN20CBaseCombatCharacter13Weapon_SwitchEP17CBaseCombatWeaponi" - "CanSpeakVoiceCommand" "_ZN22CBaseMultiplayerPlayer20CanSpeakVoiceCommandEv" - "IsReadyToSpawn" "_ZN11CBasePlayer14IsReadyToSpawnEv" - "OnTakeDamage_Alive" "_ZN20CBaseCombatCharacter18OnTakeDamage_AliveERK15CTakeDamageInfo" - "Jump" "_ZN11CBasePlayer4JumpEv" - "ProcessUserCmds" "_ZN11CBasePlayer15ProcessUsercmdsEP8CUserCmdiiib" - "GetSoundEmissionOrigin" "_ZNK11CBaseEntity22GetSoundEmissionOriginEv" - "GetServerClass" "_ZN11CBaseEntity14GetServerClassEv" - "StudioFrameAdvance" "_ZN14CBaseAnimating18StudioFrameAdvanceEv" - "ShouldGib" "_ZN9CTFPlayer9ShouldGibERK15CTakeDamageInfob" - "GetRadius" "_ZN13CTFBaseRocket9GetRadiusEv" - "DeflectPlayer" "_ZN13CTFWeaponBase13DeflectPlayerEP9CTFPlayerS1_R6VectorS3_S3_" - "GetDataDescMap" "_ZN11CBaseEntity14GetDataDescMapEv" - - // CSSDM - "IPointsForKill" "_ZN14CTeamplayRules14IPointsForKillEP11CBasePlayerS1_" - "RemoveAllItems" "_ZN11CBasePlayer14RemoveAllItemsEb" - "GiveAmmo" "_ZN20CBaseCombatCharacter8GiveAmmoEiib" - - // NapalmLagFix - "RadiusDamage" "_ZN10CGameRules12RadiusDamageERK15CTakeDamageInfoRK6VectorfiP11CBaseEntity" - - // V - "CTFFlameThrower::FireProjectile" "_ZN16CTFWeaponBaseGun14FireProjectileEP9CTFPlayer" - "CTFFlameThrower::FireFlameRocket" "_ZN16CTFWeaponBaseGun15FireFlameRocketEP9CTFPlayer" - "CTFPlayer::GetMaxHealth" "_ZNK11CBaseEntity12GetMaxHealthEv" - "CBaseEntity::GetBaseEntity" "_ZN11CBaseEntity13GetBaseEntityEv" - "RocketTouch" "_ZN13CTFBaseRocket11RocketTouchEP11CBaseEntity" - "SRocketTouch" "_ZN13CTFBaseRocket11RocketTouchEP11CBaseEntity" - - // V V - "CBaseEntity::GetModelIndex" "_ZNK11CBaseEntity13GetModelIndexEv" - "CBaseEntity::SetModelIndex" "_ZN11CBaseEntity13SetModelIndexEi" - "CBaseEntity::GetServerClass" "_ZN11CBaseEntity14GetServerClassEv" - "CBaseEntity::GetDataDescMap" "_ZN11CBaseEntity14GetDataDescMapEv" - "CBaseEntity::ShouldCollide" "_ZNK11CBaseEntity13ShouldCollideEii" - "CBaseEntity::ShouldTransmit" "_ZN11CBaseEntity14ShouldTransmitEPK18CCheckTransmitInfo" - "CBaseEntity::UpdateTransmitState" "_ZN11CBaseEntity19UpdateTransmitStateEv" - "CBaseEntity::SetTransmit" "_ZN11CBaseEntity11SetTransmitEP18CCheckTransmitInfob" - "CBaseEntity::Spawn" "_ZN11CBaseEntity5SpawnEv" - "CBaseEntity::SetModel" "_ZN11CBaseEntity8SetModelEPKc" - "CBaseEntity::KeyValue" "_ZN11CBaseEntity8KeyValueEPKcS1_" - "CBaseEntity::Activate" "_ZN11CBaseEntity8ActivateEv" - "CBaseEntity::SetParent" "_ZN11CBaseEntity9SetParentEPS_i" - "CBaseEntity::AcceptInput" "_ZN11CBaseEntity11AcceptInputEPKcPS_S2_9variant_ti" - "CBaseEntity::Think" "_ZN11CBaseEntity5ThinkEv" - "CBaseEntity::GetResponseSystem" "_ZN11CBaseEntity17GetResponseSystemEv" - "CBaseEntity::OnTakeDamage" "_ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo" - "CBaseEntity::Event_Killed" "_ZN11CBaseEntity12Event_KilledERK15CTakeDamageInfo" - "CBaseEntity::ChangeTeam" "_ZN11CBaseEntity10ChangeTeamEi" - "CBaseEntity::Use" "_ZN11CBaseEntity3UseEPS_S0_8USE_TYPEf" - "CBaseEntity::Touch" "_ZN11CBaseEntity5TouchEPS_" - "CBaseEntity::Blocked" "_ZN11CBaseEntity7BlockedEPS_" - "CBaseEntity::UpdateOnRemove" "_ZN11CBaseEntity14UpdateOnRemoveEv" - "CBaseEntity::Teleport" "_ZN11CBaseEntity8TeleportEPK6VectorPK6QAngleS2_" - "CBaseEntity::CreateVPhysics" "_ZN11CBaseEntity14CreateVPhysicsEv" - "CBaseEntity::ForceVPhysicsCollide" "_ZN11CBaseEntity20ForceVPhysicsCollideEPS_" - "CBaseEntity::VPhysicsDestroyObject" "_ZN11CBaseEntity21VPhysicsDestroyObjectEv" - "CBaseEntity::VPhysicsUpdate" "_ZN11CBaseEntity14VPhysicsUpdateEP14IPhysicsObject" - "CBaseEntity::VPhysicsTakeDamage" "_ZN11CBaseEntity18VPhysicsTakeDamageERK15CTakeDamageInfo" - "CBaseEntity::VPhysicsCollision" "_ZN11CBaseEntity17VPhysicsCollisionEiP21gamevcollisionevent_t" - "CBaseEntity::VPhysicsFriction" "_ZN11CBaseEntity16VPhysicsFrictionEP14IPhysicsObjectfii" - "CBaseEntity::VPhysicsGetObjectList" "_ZN11CBaseEntity21VPhysicsGetObjectListEPP14IPhysicsObjecti" - "CBaseEntity::PhysicsSolidMaskForEntity" "_ZNK11CBaseEntity25PhysicsSolidMaskForEntityEv" - "CBaseAnimating::StudioFrameAdvance" "_ZN14CBaseAnimating18StudioFrameAdvanceEv" - "CBaseAnimating::GetBoneTransform" "_ZN14CBaseAnimating16GetBoneTransformEiR11matrix3x4_t" - "CBaseAnimating::SetupBones" "_ZN14CBaseAnimating10SetupBonesEP11matrix3x4_ti" - "CBaseAnimating::DispatchAnimEvents" "_ZN14CBaseAnimating18DispatchAnimEventsEPS_" - "CBaseAnimating::HandleAnimEvent" "_ZN14CBaseAnimating15HandleAnimEventEP11animevent_t" - "CBaseAnimating::GetAttachment" "_ZN14CBaseAnimating13GetAttachmentEiR11matrix3x4_t" - "CBasePlayer::PlayScene" "_ZN9CTFPlayer9PlaySceneEPKcfP11AI_ResponseP16IRecipientFilter" - "CBasePlayer::GiveAmmo" "_ZN9CTFPlayer8GiveAmmoEiib" - "CBasePlayer::Weapon_Equip" "_ZN11CBasePlayer12Weapon_EquipEP17CBaseCombatWeapon" - "CBasePlayer::Weapon_Switch" "_ZN9CTFPlayer13Weapon_SwitchEP17CBaseCombatWeaponi" - "CBasePlayer::RemovePlayerItem" "_ZN11CBasePlayer16RemovePlayerItemEP17CBaseCombatWeapon" - "CBasePlayer::ForceRespawn" "_ZN9CTFPlayer12ForceRespawnEv" - "CBasePlayer::PreThink" "_ZN9CTFPlayer8PreThinkEv" - "CBasePlayer::PostThink" "_ZN9CTFPlayer9PostThinkEv" - "CTFPlayer::EquipWearable" "_ZN11CBasePlayer13EquipWearableEP13CEconWearable" - "CTFPlayer::RemoveWearable" "_ZN11CBasePlayer14RemoveWearableEP13CEconWearable" - "CBasePlayer::PlayerRunCommand" "_ZN9CTFPlayer16PlayerRunCommandEP8CUserCmdP11IMoveHelper" - "CBasePlayer::CalculateTeamBalanceScore" "_ZN9CTFPlayer25CalculateTeamBalanceScoreEv" - "CTFBaseRocket::GetWeaponID" "_ZNK13CTFBaseRocket11GetWeaponIDEv" - "CBaseCombatWeapon::ItemPostFrame" "_ZN17CBaseCombatWeapon13ItemPostFrameEv" - "CBaseCombatWeapon::Reload" "_ZN17CBaseCombatWeapon6ReloadEv" - "CBaseCombatWeapon::PrimaryAttack" "_ZN17CBaseCombatWeapon13PrimaryAttackEv" - "CBaseCombatWeapon::SecondaryAttack" "_ZN17CBaseCombatWeapon15SecondaryAttackEv" - "CBaseCombatWeapon::GetViewModel" "_ZNK17CBaseCombatWeapon12GetViewModelEi" - "CBaseCombatWeapon::GetWorldModel" "_ZNK17CBaseCombatWeapon13GetWorldModelEv" - "CBaseCombatWeapon::GetMaxClip1" "_ZNK17CBaseCombatWeapon11GetMaxClip1Ev" - "CBaseCombatWeapon::GetMaxClip2" "_ZNK17CBaseCombatWeapon11GetMaxClip2Ev" - "CBaseCombatWeapon::GetDefaultClip1" "_ZNK17CBaseCombatWeapon15GetDefaultClip1Ev" - "CBaseCombatWeapon::GetDefaultClip2" "_ZNK17CBaseCombatWeapon15GetDefaultClip2Ev" - "CBaseCombatWeapon::GetEncryptionKey" "_ZN17CBaseCombatWeapon16GetEncryptionKeyEv" - "CGameRules::CanHaveAmmo" "_ZN10CGameRules11CanHaveAmmoEP20CBaseCombatCharacterPKc" - "CGameRules::GetNextLevelName" "_ZN15CMultiplayRules16GetNextLevelNameEPcib" - "CGameRules::ChangeLevel" "_ZN15CMultiplayRules11ChangeLevelEv" - "CGameRules::GoToIntermission" "_ZN12CTFGameRules16GoToIntermissionEv" - "CGameRules::PlayerMayCapturePoint" "_ZN12CTFGameRules21PlayerMayCapturePointEP11CBasePlayeriPci" - "CTeamplayRoundBasedRules::SetWinningTeam" "_ZN24CTeamplayRoundBasedRules14SetWinningTeamEiibbb" - "CTeamplayRoundBasedRules::SetStalemate" "_ZN24CTeamplayRoundBasedRules12SetStalemateEibb" - "CTeamplayRoundBasedRules::SetScrambleTeams" "_ZN14CTeamplayRules16SetScrambleTeamsEb" - "CTeamplayRoundBasedRules::CleanUpMap" "_ZN12CTFGameRules10CleanUpMapEv" - } - - "Options" - { - "CreateGameRulesObject" "allowmultiple,allowmidfunc" - "TakeOverBot" "allowmidfunc" - "OnVersusRoundStart" "allowmidfunc" - } - } - - "#default" - { - "#supported" - { - "engine" "orangebox_valve" - "engine" "css" - "engine" "left4dead2" - "engine" "alienswarm" - "engine" "csgo" - } - - "Keys" - { - "GetMaxHealth" "_ZNK11CBaseEntity12GetMaxHealthEv" - } - } - - "#default" - { - "#supported" - { - "game" "tf" - } - - "Keys" - { - "ForceRespawn" "_ZN9CTFPlayer12ForceRespawnEv" - "GiveNamedItemTF" "_ZN9CTFPlayer13GiveNamedItemEPKciP13CEconItemViewb" - "EquipWearable" "_ZN11CBasePlayer13EquipWearableEP13CEconWearable" - "RemoveWearable" "_ZN11CBasePlayer14RemoveWearableEP13CEconWearable" - "GrenadeDetonate" "_ZN12CBaseGrenade8DetonateEv" - } - } - - "#default" - { - "#supported" - { - "engine" "css" - "engine" "orangebox_valve" - } - - "Keys" - { - "TraceAttack" "_ZN11CBaseEntity11TraceAttackERK15CTakeDamageInfoRK6VectorP10CGameTraceP15CDmgAccumulator" - } - } - - "#default" - { - "#supported" - { - "engine" "left4dead" - } - - "Keys" - { - "GiveNamedItem" "_ZN9CCSPlayer13GiveNamedItemEPKci" - } - } - - "#default" - { - "#supported" - { - "engine" "left4dead2" - } - - "Keys" - { - "GiveNamedItem" "_ZN9CCSPlayer13GiveNamedItemEPKciP11CBaseEntity" - } - } - - "#default" - { - "#supported" - { - "game" "nucleardawn" - } - "Keys" - { - "GiveNamedItem" "_ZN9CNDPlayer13GiveNamedItemEPKcib" - } - } - - "#default" - { - "#supported" - { - "engine" "csgo" - } - - "Keys" - { - "Teleport" "_ZN11CBaseEntity8TeleportEPK6VectorPK6QAngleS2_b" - "GiveNamedItem" "_ZN11CBasePlayer13GiveNamedItemEPKciP13CEconItemViewb" - } - } - - "#default" - { - "#supported" - { - "game" "synergy" - } - - "Keys" - { - "GiveNamedItem" "_ZN11CBasePlayer13GiveNamedItemEPKcib" - } - } - - "#default" - { - "#supported" - { - "engine" "original" - } - - "Keys" - { - "CommitSuicide" "_ZN11CBasePlayer13CommitSuicideEv" - "DispatchKeyValueVector" "_ZN11CBaseEntity8KeyValueEPKc6Vector" - } - } - - "#default" - { - "#supported" - { - "engine" "csgo" - } - "Keys" - { - "OnTakeDamage_Offset1" "TakeDmgPatch1" - "OnTakeDamage_Offset2" "TakeDmgPatch2" - "OnTakeDamage_Byte_Win1" "75" - "OnTakeDamage_Byte_Win2" "75" - "OnTakeDamage_Byte_Lin1" "0F" - "OnTakeDamage_Byte_Lin2" "0F" - "WantsLagComp_Offset" "LagCompPatch" - "WantsLagComp_Byte_Win" "75" - "WantsLagComp_Byte_Lin" "0F" - "CalcDominationAndRevenge_Offset" "CalcDomRevPatch" - "CalcDominationAndRevenge_Byte_Win" "0F" - "CalcDominationAndRevenge_Byte_Lin" "74" - } - } - - "#default" - { - "#supported" - { - "engine" "css" - } - "Keys" - { - "OnTakeDamage_Offset1" "TakeDmgPatch1" - "OnTakeDamage_Offset2" "TakeDmgPatch2" - "OnTakeDamage_Byte_Win1" "75" - "OnTakeDamage_Byte_Win2" "75" - "OnTakeDamage_Byte_Lin1" "0F" - "OnTakeDamage_Byte_Lin2" "0F" - "WantsLagComp_Offset" "LagCompPatch" - "WantsLagComp_Byte_Win" "75" - "WantsLagComp_Byte_Lin" "0F" - "CalcDominationAndRevenge_Offset" "CalcDomRevPatch" - "CalcDominationAndRevenge_Byte_Win" "0F" - "CalcDominationAndRevenge_Byte_Lin" "74" - } - } -} +"Games" +{ + /* + * "Keys" are used to map gamedata offset names to linux symbol. + * "Options" are used to mark validation options for windows signatures. + * Current valid options are: + * allowmultiple - don't warn if multiple matches are found + * allowmidfunc - don't warn if signature does not match the + * start of a function. + * Multiple options can be specified, separating them with a comma. + * ie. "allowmultiple,allowmidfunc" + */ + + "#default" + { + "Keys" + { + // SDKTools + "GiveNamedItem" "_ZN11CBasePlayer13GiveNamedItemEPKci" + "GiveAmmo" "_ZN20CBaseCombatCharacter8GiveAmmoEiib" + "RemovePlayerItem" "_ZN11CBasePlayer16RemovePlayerItemEP17CBaseCombatWeapon" + "Weapon_GetSlot" "_ZNK20CBaseCombatCharacter14Weapon_GetSlotEi" + "Ignite" "_ZN14CBaseAnimating6IgniteEfbfb" + "Extinguish" "_ZN14CBaseAnimating10ExtinguishEv" + "Teleport" "_ZN11CBaseEntity8TeleportEPK6VectorPK6QAngleS2_" + "CommitSuicide" "_ZN11CBasePlayer13CommitSuicideEbb" + "GetVelocity" "_ZN11CBaseEntity11GetVelocityEP6VectorS1_" + "EyeAngles" "_ZN11CBasePlayer9EyeAnglesEv" + "DispatchKeyValue" "_ZN11CBaseEntity8KeyValueEPKcS1_" + "DispatchKeyValueFloat" "_ZN11CBaseEntity8KeyValueEPKcf" + "DispatchKeyValueVector" "_ZN11CBaseEntity8KeyValueEPKcRK6Vector" + "SetEntityModel" "_ZN11CBaseEntity8SetModelEPKc" + "AcceptInput" "_ZN11CBaseEntity11AcceptInputEPKcPS_S2_9variant_ti" + "WeaponEquip" "_ZN11CBasePlayer12Weapon_EquipEP17CBaseCombatWeapon" + "Activate" "_ZN11CBaseEntity8ActivateEv" + "PlayerRunCmd" "_ZN11CBasePlayer16PlayerRunCommandEP8CUserCmdP11IMoveHelper" + + // SDKHooks + "Blocked" "_ZN11CBaseEntity7BlockedEPS_" + "EndTouch" "_ZN11CBaseEntity8EndTouchEPS_" + "FireBullets" "_ZN11CBaseEntity11FireBulletsERK17FireBulletsInfo_t" + "GroundEntChanged" "_ZN11CBaseEntity35NetworkStateChanged_m_hGroundEntityEPv" + "OnTakeDamage" "_ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo" + "OnTakeDamage_Alive" "_ZN11CBaseEntity18OnTakeDamage_AliveERK15CTakeDamageInfo" + "PreThink" "_ZN11CBasePlayer8PreThinkEv" + "PostConstructor" "_ZN11CBaseEntity15PostConstructorEPKc" + "PostThink" "_ZN11CBasePlayer9PostThinkEv" + "Reload" "_ZN17CBaseCombatWeapon6ReloadEv" + "SetTransmit" "_ZN11CBaseEntity11SetTransmitEP18CCheckTransmitInfob" + "ShouldCollide" "_ZNK11CBaseEntity13ShouldCollideEii" + "Spawn" "_ZN11CBaseEntity5SpawnEv" + "StartTouch" "_ZN11CBaseEntity10StartTouchEPS_" + "Think" "_ZN11CBaseEntity5ThinkEv" + "Touch" "_ZN11CBaseEntity5TouchEPS_" + "TraceAttack" "_ZN11CBaseEntity11TraceAttackERK15CTakeDamageInfoRK6VectorP10CGameTrace" + "UpdateOnRemove" "_ZN11CBaseEntity14UpdateOnRemoveEv" + "Use" "_ZN11CBaseEntity3UseEPS_S0_8USE_TYPEf" + "VPhysicsUpdate" "_ZN11CBaseEntity14VPhysicsUpdateEP14IPhysicsObject" + "Weapon_CanSwitchTo" "_ZN20CBaseCombatCharacter18Weapon_CanSwitchToEP17CBaseCombatWeapon" + "Weapon_CanUse" "_ZN20CBaseCombatCharacter13Weapon_CanUseEP17CBaseCombatWeapon" + "Weapon_Drop" "_ZN20CBaseCombatCharacter11Weapon_DropEP17CBaseCombatWeaponPK6VectorS4_" + "Weapon_Equip" "_ZN11CBasePlayer12Weapon_EquipEP17CBaseCombatWeapon" + "Weapon_Switch" "_ZN20CBaseCombatCharacter13Weapon_SwitchEP17CBaseCombatWeaponi" + + // CEntity extras + "FVisible" "_ZN20CBaseCombatCharacter8FVisibleEP11CBaseEntityiPS1_" + "VPhysicsTakeDamage" "_ZN11CBaseEntity18VPhysicsTakeDamageERK15CTakeDamageInfo" + "VPhysicsGetObjectList" "_ZN11CBaseEntity21VPhysicsGetObjectListEPP14IPhysicsObjecti" + "GetClientEyeAngles" "_ZN11CBaseEntity9EyeAnglesEv" + "WeaponSwitch" "_ZN20CBaseCombatCharacter13Weapon_SwitchEP17CBaseCombatWeaponi" + "CanSpeakVoiceCommand" "_ZN22CBaseMultiplayerPlayer20CanSpeakVoiceCommandEv" + "IsReadyToSpawn" "_ZN11CBasePlayer14IsReadyToSpawnEv" + "OnTakeDamage_Alive" "_ZN20CBaseCombatCharacter18OnTakeDamage_AliveERK15CTakeDamageInfo" + "Jump" "_ZN11CBasePlayer4JumpEv" + "ProcessUserCmds" "_ZN11CBasePlayer15ProcessUsercmdsEP8CUserCmdiiib" + "GetSoundEmissionOrigin" "_ZNK11CBaseEntity22GetSoundEmissionOriginEv" + "GetServerClass" "_ZN11CBaseEntity14GetServerClassEv" + "StudioFrameAdvance" "_ZN14CBaseAnimating18StudioFrameAdvanceEv" + "ShouldGib" "_ZN9CTFPlayer9ShouldGibERK15CTakeDamageInfo" + "GetRadius" "_ZN13CTFBaseRocket9GetRadiusEv" + "DeflectPlayer" "_ZN13CTFWeaponBase13DeflectPlayerEP9CTFPlayerS1_R6VectorS3_S3_" + "GetDataDescMap" "_ZN11CBaseEntity14GetDataDescMapEv" + + // TF2 ext + "CalcIsAttackCriticalHelper" "_ZN13CTFWeaponBase26CalcIsAttackCriticalHelperEv" + "CalcIsAttackCriticalHelperNoCrits" "_ZN13CTFWeaponBase33CalcIsAttackCriticalHelperNoCritsEv" + + // CSSDM + "IPointsForKill" "_ZN14CTeamplayRules14IPointsForKillEP11CBasePlayerS1_" + "RemoveAllItems" "_ZN11CBasePlayer14RemoveAllItemsEb" + "GiveAmmo" "_ZN20CBaseCombatCharacter8GiveAmmoEiib" + + // NapalmLagFix + "RadiusDamage" "_ZN10CGameRules12RadiusDamageERK15CTakeDamageInfoRK6VectorfiP11CBaseEntity" + + // V + "CTFFlameThrower::FireProjectile" "_ZN16CTFWeaponBaseGun14FireProjectileEP9CTFPlayer" + "CTFFlameThrower::FireFlameRocket" "_ZN16CTFWeaponBaseGun15FireFlameRocketEP9CTFPlayer" + "CTFPlayer::GetMaxHealth" "_ZNK11CBaseEntity12GetMaxHealthEv" + "CBaseEntity::GetBaseEntity" "_ZN11CBaseEntity13GetBaseEntityEv" + "RocketTouch" "_ZN13CTFBaseRocket11RocketTouchEP11CBaseEntity" + "SRocketTouch" "_ZN13CTFBaseRocket11RocketTouchEP11CBaseEntity" + "PlayScene" "_ZN9CTFPlayer9PlaySceneEPKcfP11AI_ResponseP16IRecipientFilter" + + // V V + "CBaseEntity::GetModelIndex" "_ZNK11CBaseEntity13GetModelIndexEv" + "CBaseEntity::SetModelIndex" "_ZN11CBaseEntity13SetModelIndexEi" + "CBaseEntity::GetServerClass" "_ZN11CBaseEntity14GetServerClassEv" + "CBaseEntity::GetDataDescMap" "_ZN11CBaseEntity14GetDataDescMapEv" + "CBaseEntity::ShouldCollide" "_ZNK11CBaseEntity13ShouldCollideEii" + "CBaseEntity::ShouldTransmit" "_ZN11CBaseEntity14ShouldTransmitEPK18CCheckTransmitInfo" + "CBaseEntity::UpdateTransmitState" "_ZN11CBaseEntity19UpdateTransmitStateEv" + "CBaseEntity::SetTransmit" "_ZN11CBaseEntity11SetTransmitEP18CCheckTransmitInfob" + "CBaseEntity::Spawn" "_ZN11CBaseEntity5SpawnEv" + "CBaseEntity::SetModel" "_ZN11CBaseEntity8SetModelEPKc" + "CBaseEntity::KeyValue" "_ZN11CBaseEntity8KeyValueEPKcS1_" + "CBaseEntity::Activate" "_ZN11CBaseEntity8ActivateEv" + "CBaseEntity::SetParent" "_ZN11CBaseEntity9SetParentEPS_i" + "CBaseEntity::AcceptInput" "_ZN11CBaseEntity11AcceptInputEPKcPS_S2_9variant_ti" + "CBaseEntity::Think" "_ZN11CBaseEntity5ThinkEv" + "CBaseEntity::GetResponseSystem" "_ZN11CBaseEntity17GetResponseSystemEv" + "CBaseEntity::OnTakeDamage" "_ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo" + "CBaseEntity::Event_Killed" "_ZN11CBaseEntity12Event_KilledERK15CTakeDamageInfo" + "CBaseEntity::ChangeTeam" "_ZN11CBaseEntity10ChangeTeamEi" + "CBaseEntity::Use" "_ZN11CBaseEntity3UseEPS_S0_8USE_TYPEf" + "CBaseEntity::Touch" "_ZN11CBaseEntity5TouchEPS_" + "CBaseEntity::Blocked" "_ZN11CBaseEntity7BlockedEPS_" + "CBaseEntity::UpdateOnRemove" "_ZN11CBaseEntity14UpdateOnRemoveEv" + "CBaseEntity::Teleport" "_ZN11CBaseEntity8TeleportEPK6VectorPK6QAngleS2_" + "CBaseEntity::CreateVPhysics" "_ZN11CBaseEntity14CreateVPhysicsEv" + "CBaseEntity::ForceVPhysicsCollide" "_ZN11CBaseEntity20ForceVPhysicsCollideEPS_" + "CBaseEntity::VPhysicsDestroyObject" "_ZN11CBaseEntity21VPhysicsDestroyObjectEv" + "CBaseEntity::VPhysicsUpdate" "_ZN11CBaseEntity14VPhysicsUpdateEP14IPhysicsObject" + "CBaseEntity::VPhysicsTakeDamage" "_ZN11CBaseEntity18VPhysicsTakeDamageERK15CTakeDamageInfo" + "CBaseEntity::VPhysicsCollision" "_ZN11CBaseEntity17VPhysicsCollisionEiP21gamevcollisionevent_t" + "CBaseEntity::VPhysicsFriction" "_ZN11CBaseEntity16VPhysicsFrictionEP14IPhysicsObjectfii" + "CBaseEntity::VPhysicsGetObjectList" "_ZN11CBaseEntity21VPhysicsGetObjectListEPP14IPhysicsObjecti" + "CBaseEntity::PhysicsSolidMaskForEntity" "_ZNK11CBaseEntity25PhysicsSolidMaskForEntityEv" + "CBaseAnimating::StudioFrameAdvance" "_ZN14CBaseAnimating18StudioFrameAdvanceEv" + "CBaseAnimating::GetBoneTransform" "_ZN14CBaseAnimating16GetBoneTransformEiR11matrix3x4_t" + "CBaseAnimating::SetupBones" "_ZN14CBaseAnimating10SetupBonesEP11matrix3x4_ti" + "CBaseAnimating::DispatchAnimEvents" "_ZN14CBaseAnimating18DispatchAnimEventsEPS_" + "CBaseAnimating::HandleAnimEvent" "_ZN14CBaseAnimating15HandleAnimEventEP11animevent_t" + "CBaseAnimating::GetAttachment" "_ZN14CBaseAnimating13GetAttachmentEiR11matrix3x4_t" + "CBasePlayer::PlayScene" "_ZN9CTFPlayer9PlaySceneEPKcfP11AI_ResponseP16IRecipientFilter" + "CBasePlayer::GiveAmmo" "_ZN9CTFPlayer8GiveAmmoEiib" + "CBasePlayer::Weapon_Equip" "_ZN11CBasePlayer12Weapon_EquipEP17CBaseCombatWeapon" + "CBasePlayer::Weapon_Switch" "_ZN9CTFPlayer13Weapon_SwitchEP17CBaseCombatWeaponi" + "CBasePlayer::RemovePlayerItem" "_ZN11CBasePlayer16RemovePlayerItemEP17CBaseCombatWeapon" + "CBasePlayer::ForceRespawn" "_ZN9CTFPlayer12ForceRespawnEv" + "CBasePlayer::PreThink" "_ZN9CTFPlayer8PreThinkEv" + "CBasePlayer::PostThink" "_ZN9CTFPlayer9PostThinkEv" + "CTFPlayer::EquipWearable" "_ZN11CBasePlayer13EquipWearableEP13CEconWearable" + "CTFPlayer::RemoveWearable" "_ZN11CBasePlayer14RemoveWearableEP13CEconWearable" + "CBasePlayer::PlayerRunCommand" "_ZN9CTFPlayer16PlayerRunCommandEP8CUserCmdP11IMoveHelper" + "CBasePlayer::CalculateTeamBalanceScore" "_ZN9CTFPlayer25CalculateTeamBalanceScoreEv" + "CTFBaseRocket::GetWeaponID" "_ZNK13CTFBaseRocket11GetWeaponIDEv" + "CBaseCombatWeapon::ItemPostFrame" "_ZN17CBaseCombatWeapon13ItemPostFrameEv" + "CBaseCombatWeapon::Reload" "_ZN17CBaseCombatWeapon6ReloadEv" + "CBaseCombatWeapon::PrimaryAttack" "_ZN17CBaseCombatWeapon13PrimaryAttackEv" + "CBaseCombatWeapon::SecondaryAttack" "_ZN17CBaseCombatWeapon15SecondaryAttackEv" + "CBaseCombatWeapon::GetViewModel" "_ZNK17CBaseCombatWeapon12GetViewModelEi" + "CBaseCombatWeapon::GetWorldModel" "_ZNK17CBaseCombatWeapon13GetWorldModelEv" + "CBaseCombatWeapon::GetMaxClip1" "_ZNK17CBaseCombatWeapon11GetMaxClip1Ev" + "CBaseCombatWeapon::GetMaxClip2" "_ZNK17CBaseCombatWeapon11GetMaxClip2Ev" + "CBaseCombatWeapon::GetDefaultClip1" "_ZNK17CBaseCombatWeapon15GetDefaultClip1Ev" + "CBaseCombatWeapon::GetDefaultClip2" "_ZNK17CBaseCombatWeapon15GetDefaultClip2Ev" + "CBaseCombatWeapon::GetEncryptionKey" "_ZN17CBaseCombatWeapon16GetEncryptionKeyEv" + "CGameRules::CanHaveAmmo" "_ZN10CGameRules11CanHaveAmmoEP20CBaseCombatCharacterPKc" + "CGameRules::GetNextLevelName" "_ZN15CMultiplayRules16GetNextLevelNameEPcib" + "CGameRules::ChangeLevel" "_ZN15CMultiplayRules11ChangeLevelEv" + "CGameRules::GoToIntermission" "_ZN12CTFGameRules16GoToIntermissionEv" + "CGameRules::PlayerMayCapturePoint" "_ZN12CTFGameRules21PlayerMayCapturePointEP11CBasePlayeriPci" + "CTeamplayRoundBasedRules::SetWinningTeam" "_ZN24CTeamplayRoundBasedRules14SetWinningTeamEiibbb" + "CTeamplayRoundBasedRules::SetStalemate" "_ZN24CTeamplayRoundBasedRules12SetStalemateEibb" + "CTeamplayRoundBasedRules::SetScrambleTeams" "_ZN14CTeamplayRules16SetScrambleTeamsEb" + "CTeamplayRoundBasedRules::CleanUpMap" "_ZN12CTFGameRules10CleanUpMapEv" + + "IsValidObserverTarget" "_ZN11CBasePlayer21IsValidObserverTargetEP11CBaseEntity" + } + + "Options" + { + "CreateGameRulesObject" "allowmultiple,allowmidfunc" + "TakeOverBot" "allowmidfunc" + "OnVersusRoundStart" "allowmidfunc" + } + } + + "#default" + { + "#supported" + { + "engine" "orangebox_valve" + "engine" "sdk2013" + "engine" "css" + "engine" "left4dead2" + "engine" "alienswarm" + "engine" "csgo" + "engine" "insurgency" + } + + "Keys" + { + "GetMaxHealth" "_ZNK11CBaseEntity12GetMaxHealthEv" + } + } + + "#default" + { + "#supported" + { + "game" "tf" + } + + "Keys" + { + "ForceRespawn" "_ZN9CTFPlayer12ForceRespawnEv" + "GiveNamedItemTF" "_ZN9CTFPlayer13GiveNamedItemEPKciP13CEconItemViewb" + "EquipWearable" "_ZN11CBasePlayer13EquipWearableEP13CEconWearable" + "RemoveWearable" "_ZN11CBasePlayer14RemoveWearableEP13CEconWearable" + "GrenadeDetonate" "_ZN12CBaseGrenade8DetonateEv" + } + } + + "#default" + { + "#supported" + { + "engine" "css" + "engine" "sdk2013" + "engine" "orangebox_valve" + } + + "Keys" + { + "TraceAttack" "_ZN11CBaseEntity11TraceAttackERK15CTakeDamageInfoRK6VectorP10CGameTraceP15CDmgAccumulator" + } + } + + "#default" + { + "#supported" + { + "engine" "left4dead" + } + + "Keys" + { + "GiveNamedItem" "_ZN9CCSPlayer13GiveNamedItemEPKci" + } + } + + "#default" + { + "#supported" + { + "engine" "left4dead2" + } + + "Keys" + { + "GiveNamedItem" "_ZN9CCSPlayer13GiveNamedItemEPKciP11CBaseEntity" + } + } + + "csgo" + { + "Keys" + { + "GiveNamedItem" "_ZN11CBasePlayer13GiveNamedItemEPKciP13CEconItemViewb" + } + } + + "#default" + { + "#supported" + { + "engine" "csgo" + "engine" "insurgency" + } + + "Keys" + { + "Teleport" "_ZN11CBaseEntity8TeleportEPK6VectorPK6QAngleS2_b" + } + } + + "insurgency" + { + "Keys" + { + "GiveNamedItem" "_ZN11CBasePlayer13GiveNamedItemEPKcib" + } + } + + "#default" + { + "#supported" + { + "engine" "nucleardawn" + "game" "synergy" + } + + "Keys" + { + "GiveNamedItem" "_ZN11CBasePlayer13GiveNamedItemEPKcib" + } + } + + "#default" + { + "#supported" + { + "engine" "original" + } + + "Keys" + { + "CommitSuicide" "_ZN11CBasePlayer13CommitSuicideEv" + "DispatchKeyValueVector" "_ZN11CBaseEntity8KeyValueEPKc6Vector" + } + } + + "#default" + { + "#supported" + { + "engine" "csgo" + } + "Keys" + { + "OnTakeDamage_Offset1" "TakeDmgPatch1" + "OnTakeDamage_Offset2" "TakeDmgPatch2" + "OnTakeDamage_Byte_Win1" "75" + "OnTakeDamage_Byte_Win2" "75" + "OnTakeDamage_Byte_Lin1" "0F" + "OnTakeDamage_Byte_Lin2" "0F" + "WantsLagComp_Offset" "LagCompPatch" + "WantsLagComp_Byte_Win" "75" + "WantsLagComp_Byte_Lin" "0F" + "CalcDominationAndRevenge_Offset" "CalcDomRevPatch" + "CalcDominationAndRevenge_Byte_Win" "0F" + "CalcDominationAndRevenge_Byte_Lin" "74" + "GetWeaponPrice_Offset" "GetWeaponPriceFuncGDC" + "GetWeaponPrice_Byte_Win" "E9" + } + } + + "#default" + { + "#supported" + { + "engine" "css" + } + "Keys" + { + "OnTakeDamage_Offset1" "TakeDmgPatch1" + "OnTakeDamage_Offset2" "TakeDmgPatch2" + "OnTakeDamage_Byte_Win1" "75" + "OnTakeDamage_Byte_Win2" "75" + "OnTakeDamage_Byte_Lin1" "0F" + "OnTakeDamage_Byte_Lin2" "0F" + "WantsLagComp_Offset" "LagCompPatch" + "WantsLagComp_Byte_Win" "75" + "WantsLagComp_Byte_Lin" "0F" + "CalcDominationAndRevenge_Offset" "CalcDomRevPatch" + "CalcDominationAndRevenge_Byte_Win" "0F" + "CalcDominationAndRevenge_Byte_Lin" "74" + } + } + + "nmrih" + { + "Keys" + { + "Ignite" "_ZN14CBaseAnimating6IgniteEfbfbP11CBaseEntity8string_t" + } + } +} diff --git a/translations/playercommands.phrases.txt b/translations/playercommands.phrases.txt index 1adb848d..a56b1ec9 100644 --- a/translations/playercommands.phrases.txt +++ b/translations/playercommands.phrases.txt @@ -15,12 +15,6 @@ { "en" "Rename player" } - - "Dead Player Rename" - { - "#format" "{1:s}" - "en" "{1} will be renamed on the next round." - } "Slap player" {